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.
This commit is contained in:
@@ -201,14 +201,8 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
|
||||
public void setHealth(int i) {
|
||||
super.setHealth(i);
|
||||
Collection collection = this.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.f);
|
||||
Iterator iterator = collection.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
ScoreboardObjective scoreboardobjective = (ScoreboardObjective) iterator.next();
|
||||
|
||||
this.getScoreboard().getPlayerScoreForObjective(this.getLocalizedName(), scoreboardobjective).updateForList(Arrays.asList(new EntityHuman[] { this}));
|
||||
}
|
||||
// CraftBukkit - Update ALL the scores!
|
||||
this.world.getServer().getScoreboardManager().updateAllScoresForList(IScoreboardCriteria.f, this.getLocalizedName(), com.google.common.collect.ImmutableList.of(this));
|
||||
}
|
||||
|
||||
public void g() {
|
||||
@@ -304,12 +298,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
||||
this.closeInventory();
|
||||
// CraftBukkit end
|
||||
|
||||
Collection collection = this.world.getScoreboard().getObjectivesForCriteria(IScoreboardCriteria.c);
|
||||
// CraftBukkit - Get our scores instead
|
||||
Collection<ScoreboardScore> collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.c, this.getLocalizedName(), new java.util.ArrayList<ScoreboardScore>());
|
||||
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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user