diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/server/ServerScoreboard.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/server/ServerScoreboard.java.patch | 262 |
1 files changed, 262 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/server/ServerScoreboard.java.patch b/patch-remap/mache-spigotflower/net/minecraft/server/ServerScoreboard.java.patch new file mode 100644 index 0000000000..a45a693ffe --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/server/ServerScoreboard.java.patch @@ -0,0 +1,262 @@ +--- a/net/minecraft/server/ServerScoreboard.java ++++ b/net/minecraft/server/ServerScoreboard.java +@@ -32,66 +32,61 @@ + private final Set<Objective> trackedObjectives = Sets.newHashSet(); + private final List<Runnable> dirtyListeners = Lists.newArrayList(); + +- public ServerScoreboard(MinecraftServer minecraftserver) { +- this.server = minecraftserver; ++ public ServerScoreboard(MinecraftServer server) { ++ this.server = server; + } + + @Override +- @Override +- protected void onScoreChanged(ScoreHolder scoreholder, Objective objective, Score score) { +- super.onScoreChanged(scoreholder, objective, score); +- if (this.trackedObjectives.contains(objective)) { +- this.server.getPlayerList().broadcastAll(new ClientboundSetScorePacket(scoreholder.getScoreboardName(), objective.getName(), score.value(), score.display(), score.numberFormat())); ++ protected void onScoreChanged(ScoreHolder scoreholder, Objective scoreboardobjective, Score scoreboardscore) { ++ super.onScoreChanged(scoreholder, scoreboardobjective, scoreboardscore); ++ if (this.trackedObjectives.contains(scoreboardobjective)) { ++ this.broadcastAll(new ClientboundSetScorePacket(scoreholder.getScoreboardName(), scoreboardobjective.getName(), scoreboardscore.value(), scoreboardscore.display(), scoreboardscore.numberFormat())); // CraftBukkit + } + + this.setDirty(); + } + + @Override +- @Override +- protected void onScoreLockChanged(ScoreHolder scoreholder, Objective objective) { +- super.onScoreLockChanged(scoreholder, objective); ++ protected void onScoreLockChanged(ScoreHolder scoreholder, Objective scoreboardobjective) { ++ super.onScoreLockChanged(scoreholder, scoreboardobjective); + this.setDirty(); + } + + @Override +- @Override + public void onPlayerRemoved(ScoreHolder scoreholder) { + super.onPlayerRemoved(scoreholder); +- this.server.getPlayerList().broadcastAll(new ClientboundResetScorePacket(scoreholder.getScoreboardName(), (String) null)); ++ this.broadcastAll(new ClientboundResetScorePacket(scoreholder.getScoreboardName(), (String) null)); // CraftBukkit + this.setDirty(); + } + + @Override +- @Override +- public void onPlayerScoreRemoved(ScoreHolder scoreholder, Objective objective) { +- super.onPlayerScoreRemoved(scoreholder, objective); +- if (this.trackedObjectives.contains(objective)) { +- this.server.getPlayerList().broadcastAll(new ClientboundResetScorePacket(scoreholder.getScoreboardName(), objective.getName())); ++ public void onPlayerScoreRemoved(ScoreHolder scoreholder, Objective scoreboardobjective) { ++ super.onPlayerScoreRemoved(scoreholder, scoreboardobjective); ++ if (this.trackedObjectives.contains(scoreboardobjective)) { ++ this.broadcastAll(new ClientboundResetScorePacket(scoreholder.getScoreboardName(), scoreboardobjective.getName())); // CraftBukkit + } + + this.setDirty(); + } + + @Override +- @Override +- public void setDisplayObjective(DisplaySlot displayslot, @Nullable Objective objective) { +- Objective objective1 = this.getDisplayObjective(displayslot); ++ public void setDisplayObjective(DisplaySlot displayslot, @Nullable Objective scoreboardobjective) { ++ Objective scoreboardobjective1 = this.getDisplayObjective(displayslot); + +- super.setDisplayObjective(displayslot, objective); +- if (objective1 != objective && objective1 != null) { +- if (this.getObjectiveDisplaySlotCount(objective1) > 0) { +- this.server.getPlayerList().broadcastAll(new ClientboundSetDisplayObjectivePacket(displayslot, objective)); ++ super.setDisplayObjective(displayslot, scoreboardobjective); ++ if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) { ++ if (this.getObjectiveDisplaySlotCount(scoreboardobjective1) > 0) { ++ this.broadcastAll(new ClientboundSetDisplayObjectivePacket(displayslot, scoreboardobjective)); // CraftBukkit + } else { +- this.stopTrackingObjective(objective1); ++ this.stopTrackingObjective(scoreboardobjective1); + } + } + +- if (objective != null) { +- if (this.trackedObjectives.contains(objective)) { +- this.server.getPlayerList().broadcastAll(new ClientboundSetDisplayObjectivePacket(displayslot, objective)); ++ if (scoreboardobjective != null) { ++ if (this.trackedObjectives.contains(scoreboardobjective)) { ++ this.broadcastAll(new ClientboundSetDisplayObjectivePacket(displayslot, scoreboardobjective)); // CraftBukkit + } else { +- this.startTrackingObjective(objective); ++ this.startTrackingObjective(scoreboardobjective); + } + } + +@@ -99,10 +94,9 @@ + } + + @Override +- @Override +- public boolean addPlayerToTeam(String s, PlayerTeam playerteam) { +- if (super.addPlayerToTeam(s, playerteam)) { +- this.server.getPlayerList().broadcastAll(ClientboundSetPlayerTeamPacket.createPlayerPacket(playerteam, s, ClientboundSetPlayerTeamPacket.Action.ADD)); ++ public boolean addPlayerToTeam(String playerName, PlayerTeam team) { ++ if (super.addPlayerToTeam(playerName, team)) { ++ this.broadcastAll(ClientboundSetPlayerTeamPacket.createPlayerPacket(team, playerName, ClientboundSetPlayerTeamPacket.a.ADD)); // CraftBukkit + this.setDirty(); + return true; + } else { +@@ -111,33 +105,29 @@ + } + + @Override +- @Override +- public void removePlayerFromTeam(String s, PlayerTeam playerteam) { +- super.removePlayerFromTeam(s, playerteam); +- this.server.getPlayerList().broadcastAll(ClientboundSetPlayerTeamPacket.createPlayerPacket(playerteam, s, ClientboundSetPlayerTeamPacket.Action.REMOVE)); ++ public void removePlayerFromTeam(String username, PlayerTeam playerTeam) { ++ super.removePlayerFromTeam(username, playerTeam); ++ this.broadcastAll(ClientboundSetPlayerTeamPacket.createPlayerPacket(playerTeam, username, ClientboundSetPlayerTeamPacket.a.REMOVE)); // CraftBukkit + this.setDirty(); + } + + @Override +- @Override + public void onObjectiveAdded(Objective objective) { + super.onObjectiveAdded(objective); + this.setDirty(); + } + + @Override +- @Override + public void onObjectiveChanged(Objective objective) { + super.onObjectiveChanged(objective); + if (this.trackedObjectives.contains(objective)) { +- this.server.getPlayerList().broadcastAll(new ClientboundSetObjectivePacket(objective, 2)); ++ this.broadcastAll(new ClientboundSetObjectivePacket(objective, 2)); // CraftBukkit + } + + this.setDirty(); + } + + @Override +- @Override + public void onObjectiveRemoved(Objective objective) { + super.onObjectiveRemoved(objective); + if (this.trackedObjectives.contains(objective)) { +@@ -148,26 +138,23 @@ + } + + @Override +- @Override +- public void onTeamAdded(PlayerTeam playerteam) { +- super.onTeamAdded(playerteam); +- this.server.getPlayerList().broadcastAll(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(playerteam, true)); ++ public void onTeamAdded(PlayerTeam playerTeam) { ++ super.onTeamAdded(playerTeam); ++ this.broadcastAll(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(playerTeam, true)); // CraftBukkit + this.setDirty(); + } + + @Override +- @Override +- public void onTeamChanged(PlayerTeam playerteam) { +- super.onTeamChanged(playerteam); +- this.server.getPlayerList().broadcastAll(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(playerteam, false)); ++ public void onTeamChanged(PlayerTeam playerTeam) { ++ super.onTeamChanged(playerTeam); ++ this.broadcastAll(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(playerTeam, false)); // CraftBukkit + this.setDirty(); + } + + @Override +- @Override +- public void onTeamRemoved(PlayerTeam playerteam) { +- super.onTeamRemoved(playerteam); +- this.server.getPlayerList().broadcastAll(ClientboundSetPlayerTeamPacket.createRemovePacket(playerteam)); ++ public void onTeamRemoved(PlayerTeam playerTeam) { ++ super.onTeamRemoved(playerTeam); ++ this.broadcastAll(ClientboundSetPlayerTeamPacket.createRemovePacket(playerTeam)); // CraftBukkit + this.setDirty(); + } + +@@ -217,13 +204,14 @@ + Iterator iterator = this.server.getPlayerList().getPlayers().iterator(); + + while (iterator.hasNext()) { +- ServerPlayer serverplayer = (ServerPlayer) iterator.next(); ++ ServerPlayer entityplayer = (ServerPlayer) iterator.next(); ++ if (entityplayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board + Iterator iterator1 = list.iterator(); + + while (iterator1.hasNext()) { + Packet<?> packet = (Packet) iterator1.next(); + +- serverplayer.connection.send(packet); ++ entityplayer.connection.send(packet); + } + } + +@@ -253,13 +241,14 @@ + Iterator iterator = this.server.getPlayerList().getPlayers().iterator(); + + while (iterator.hasNext()) { +- ServerPlayer serverplayer = (ServerPlayer) iterator.next(); ++ ServerPlayer entityplayer = (ServerPlayer) iterator.next(); ++ if (entityplayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board + Iterator iterator1 = list.iterator(); + + while (iterator1.hasNext()) { + Packet<?> packet = (Packet) iterator1.next(); + +- serverplayer.connection.send(packet); ++ entityplayer.connection.send(packet); + } + } + +@@ -282,26 +271,36 @@ + return i; + } + +- public SavedData.Factory<ScoreboardSaveData> dataFactory() { +- return new SavedData.Factory<>(this::createData, this::createData, DataFixTypes.SAVED_DATA_SCOREBOARD); ++ public SavedData.a<ScoreboardSaveData> dataFactory() { ++ return new SavedData.a<>(this::createData, this::createData, DataFixTypes.SAVED_DATA_SCOREBOARD); + } + + private ScoreboardSaveData createData() { +- ScoreboardSaveData scoreboardsavedata = new ScoreboardSaveData(this); ++ ScoreboardSaveData persistentscoreboard = new ScoreboardSaveData(this); + +- Objects.requireNonNull(scoreboardsavedata); +- this.addDirtyListener(scoreboardsavedata::setDirty); +- return scoreboardsavedata; ++ Objects.requireNonNull(persistentscoreboard); ++ this.addDirtyListener(persistentscoreboard::setDirty); ++ return persistentscoreboard; + } + +- private ScoreboardSaveData createData(CompoundTag compoundtag) { +- return this.createData().load(compoundtag); ++ private ScoreboardSaveData createData(CompoundTag tag) { ++ return this.createData().load(tag); + } + +- public static enum Method { ++ // CraftBukkit start - Send to players ++ private void broadcastAll(Packet packet) { ++ for (ServerPlayer entityplayer : (List<ServerPlayer>) this.server.getPlayerList().players) { ++ if (entityplayer.getBukkitEntity().getScoreboard().getHandle() == this) { ++ entityplayer.connection.send(packet); ++ } ++ } ++ } ++ // CraftBukkit end + ++ public static enum Action { ++ + CHANGE, REMOVE; + +- private Method() {} ++ private Action() {} + } + } |