summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/EntityHuman.java
diff options
context:
space:
mode:
authormbax <matt@phozop.net>2013-03-22 17:21:33 -0400
committerWesley Wolfe <weswolf@aol.com>2013-04-04 01:13:21 -0500
commitd95a4705cb35319c3456197229be4c6de4cbd521 (patch)
tree85fbcdb3085314c548698f6e2161501a4e7477e7 /src/main/java/net/minecraft/server/EntityHuman.java
parent5634d9f701acea733fbe8c0f47c60369acfd56cd (diff)
downloadcraftbukkit-d95a4705cb35319c3456197229be4c6de4cbd521.tar
craftbukkit-d95a4705cb35319c3456197229be4c6de4cbd521.tar.gz
craftbukkit-d95a4705cb35319c3456197229be4c6de4cbd521.tar.lz
craftbukkit-d95a4705cb35319c3456197229be4c6de4cbd521.tar.xz
craftbukkit-d95a4705cb35319c3456197229be4c6de4cbd521.zip
Implement Scoreboard API. Adds BUKKIT-3776
This implementation facilitates the correspondence of the Bukkit Scoreboard API to the internal minecraft implementation. When the first scoreboard is loaded, the scoreboard manager will be created. It uses the newly added WeakCollection for handling plugin scoreboard references to update the respective objectives. When a scoreboard contains no more active references, it should be garbage collected. An active reference can be held by a still registered objective, team, and transitively a score for a still registered objective. An internal reference will also be kept if a player's specific scoreboard has been set, and will remain persistent until that player logs out. A player's specific scoreboard becomes the scoreboard used when determining team structure for the player's attacking damage and the player's vision.
Diffstat (limited to 'src/main/java/net/minecraft/server/EntityHuman.java')
-rw-r--r--src/main/java/net/minecraft/server/EntityHuman.java34
1 files changed, 27 insertions, 7 deletions
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index 101c2a0d..91b44a03 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -436,11 +436,13 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen
public void c(Entity entity, int i) {
this.addScore(i);
- Collection collection = this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.e);
+ // CraftBukkit - Get our scores instead
+ Collection<ScoreboardScore> collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.e, this.getLocalizedName(), new java.util.ArrayList<ScoreboardScore>());
if (entity instanceof EntityHuman) {
this.a(StatisticList.A, 1);
- collection.addAll(this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.d));
+ // CraftBukkit - Get our scores instead
+ this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.d, this.getLocalizedName(), collection);
} else {
this.a(StatisticList.z, 1);
}
@@ -448,8 +450,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen
Iterator iterator = collection.iterator();
while (iterator.hasNext()) {
- ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next();
- ScoreboardScore scoreboardscore = this.getScoreboard().getPlayerScoreForObjective(this.getLocalizedName(), scoreboardobjective);
+ ScoreboardScore scoreboardscore = (ScoreboardScore) iterator.next(); // CraftBukkit - Use our scores instead
scoreboardscore.incrementScore();
}
@@ -687,10 +688,28 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen
}
public boolean a(EntityHuman entityhuman) {
- ScoreboardTeam scoreboardteam = this.getScoreboardTeam();
- ScoreboardTeam scoreboardteam1 = entityhuman.getScoreboardTeam();
+ // CraftBukkit start - Change to check player's scoreboard team according to API reference to this (or main) scoreboard
+ org.bukkit.scoreboard.Team team;
+ if (this instanceof EntityPlayer) {
+ EntityPlayer thisPlayer = (EntityPlayer) this;
+ team = thisPlayer.getBukkitEntity().getScoreboard().getPlayerTeam(thisPlayer.getBukkitEntity());
+ if (team == null || team.allowFriendlyFire()) {
+ return true;
+ }
+ } else {
+ // This should never be called, but is implemented anyway
+ org.bukkit.OfflinePlayer thisPlayer = this.world.getServer().getOfflinePlayer(this.name);
+ team = this.world.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer);
+ if (team == null || team.allowFriendlyFire()) {
+ return true;
+ }
+ }
- return scoreboardteam != scoreboardteam1 ? true : (scoreboardteam != null ? scoreboardteam.allowFriendlyFire() : true);
+ if (entityhuman instanceof EntityPlayer) {
+ return team.hasPlayer(((EntityPlayer) entityhuman).getBukkitEntity());
+ }
+ return team.hasPlayer(this.world.getServer().getOfflinePlayer(entityhuman.name));
+ // CraftBukkit end
}
protected void a(EntityLiving entityliving, boolean flag) {
@@ -1494,6 +1513,7 @@ public abstract class EntityHuman extends EntityLiving implements ICommandListen
}
public String getScoreboardDisplayName() {
+ // TODO: fun
return ScoreboardTeam.getPlayerDisplayName(this.getScoreboardTeam(), this.name);
}
}