aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/server/ServerScoreboard.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/server/ServerScoreboard.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/server/ServerScoreboard.java.patch340
1 files changed, 340 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/server/ServerScoreboard.java.patch b/patch-remap/mache-vineflower/net/minecraft/server/ServerScoreboard.java.patch
new file mode 100644
index 0000000000..5c8085db82
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/server/ServerScoreboard.java.patch
@@ -0,0 +1,340 @@
+--- a/net/minecraft/server/ServerScoreboard.java
++++ b/net/minecraft/server/ServerScoreboard.java
+@@ -2,7 +2,9 @@
+
+ import com.google.common.collect.Lists;
+ import com.google.common.collect.Sets;
++import java.util.Iterator;
+ import java.util.List;
++import java.util.Objects;
+ import java.util.Set;
+ import javax.annotation.Nullable;
+ import net.minecraft.nbt.CompoundTag;
+@@ -25,6 +27,7 @@
+ import net.minecraft.world.scores.ScoreboardSaveData;
+
+ public class ServerScoreboard extends Scoreboard {
++
+ private final MinecraftServer server;
+ private final Set<Objective> trackedObjectives = Sets.newHashSet();
+ private final List<Runnable> dirtyListeners = Lists.newArrayList();
+@@ -34,59 +37,56 @@
+ }
+
+ @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
+- 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
+- public void onPlayerRemoved(ScoreHolder scoreHolder) {
+- super.onPlayerRemoved(scoreHolder);
+- this.server.getPlayerList().broadcastAll(new ClientboundResetScorePacket(scoreHolder.getScoreboardName(), null));
++ public void onPlayerRemoved(ScoreHolder scoreholder) {
++ super.onPlayerRemoved(scoreholder);
++ this.broadcastAll(new ClientboundResetScorePacket(scoreholder.getScoreboardName(), (String) null)); // CraftBukkit
+ this.setDirty();
+ }
+
+ @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
+- public void setDisplayObjective(DisplaySlot displaySlot, @Nullable Objective objective) {
+- Objective displayObjective = this.getDisplayObjective(displaySlot);
+- super.setDisplayObjective(displaySlot, objective);
+- if (displayObjective != objective && displayObjective != null) {
+- if (this.getObjectiveDisplaySlotCount(displayObjective) > 0) {
+- this.server.getPlayerList().broadcastAll(new ClientboundSetDisplayObjectivePacket(displaySlot, objective));
++ public void setDisplayObjective(DisplaySlot displayslot, @Nullable Objective scoreboardobjective) {
++ Objective scoreboardobjective1 = this.getDisplayObjective(displayslot);
++
++ super.setDisplayObjective(displayslot, scoreboardobjective);
++ if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) {
++ if (this.getObjectiveDisplaySlotCount(scoreboardobjective1) > 0) {
++ this.broadcastAll(new ClientboundSetDisplayObjectivePacket(displayslot, scoreboardobjective)); // CraftBukkit
+ } else {
+- this.stopTrackingObjective(displayObjective);
++ 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);
+ }
+ }
+
+@@ -96,9 +96,7 @@
+ @Override
+ public boolean addPlayerToTeam(String playerName, PlayerTeam team) {
+ if (super.addPlayerToTeam(playerName, team)) {
+- this.server
+- .getPlayerList()
+- .broadcastAll(ClientboundSetPlayerTeamPacket.createPlayerPacket(team, playerName, ClientboundSetPlayerTeamPacket.Action.ADD));
++ this.broadcastAll(ClientboundSetPlayerTeamPacket.createPlayerPacket(team, playerName, ClientboundSetPlayerTeamPacket.a.ADD)); // CraftBukkit
+ this.setDirty();
+ return true;
+ } else {
+@@ -109,9 +107,7 @@
+ @Override
+ public void removePlayerFromTeam(String username, PlayerTeam playerTeam) {
+ super.removePlayerFromTeam(username, playerTeam);
+- this.server
+- .getPlayerList()
+- .broadcastAll(ClientboundSetPlayerTeamPacket.createPlayerPacket(playerTeam, username, ClientboundSetPlayerTeamPacket.Action.REMOVE));
++ this.broadcastAll(ClientboundSetPlayerTeamPacket.createPlayerPacket(playerTeam, username, ClientboundSetPlayerTeamPacket.a.REMOVE)); // CraftBukkit
+ this.setDirty();
+ }
+
+@@ -125,7 +121,7 @@
+ 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();
+@@ -144,21 +140,21 @@
+ @Override
+ public void onTeamAdded(PlayerTeam playerTeam) {
+ super.onTeamAdded(playerTeam);
+- this.server.getPlayerList().broadcastAll(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(playerTeam, true));
++ this.broadcastAll(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(playerTeam, true)); // CraftBukkit
+ this.setDirty();
+ }
+
+ @Override
+ public void onTeamChanged(PlayerTeam playerTeam) {
+ super.onTeamChanged(playerTeam);
+- this.server.getPlayerList().broadcastAll(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(playerTeam, false));
++ this.broadcastAll(ClientboundSetPlayerTeamPacket.createAddOrModifyPacket(playerTeam, false)); // CraftBukkit
+ this.setDirty();
+ }
+
+ @Override
+ public void onTeamRemoved(PlayerTeam playerTeam) {
+ super.onTeamRemoved(playerTeam);
+- this.server.getPlayerList().broadcastAll(ClientboundSetPlayerTeamPacket.createRemovePacket(playerTeam));
++ this.broadcastAll(ClientboundSetPlayerTeamPacket.createRemovePacket(playerTeam)); // CraftBukkit
+ this.setDirty();
+ }
+
+@@ -167,42 +163,55 @@
+ }
+
+ protected void setDirty() {
+- for (Runnable runnable : this.dirtyListeners) {
++ Iterator iterator = this.dirtyListeners.iterator();
++
++ while (iterator.hasNext()) {
++ Runnable runnable = (Runnable) iterator.next();
++
+ runnable.run();
+ }
++
+ }
+
+ public List<Packet<?>> getStartTrackingPackets(Objective objective) {
+ List<Packet<?>> list = Lists.newArrayList();
++
+ list.add(new ClientboundSetObjectivePacket(objective, 0));
++ DisplaySlot[] adisplayslot = DisplaySlot.values();
++ int i = adisplayslot.length;
+
+- for (DisplaySlot displaySlot : DisplaySlot.values()) {
+- if (this.getDisplayObjective(displaySlot) == objective) {
+- list.add(new ClientboundSetDisplayObjectivePacket(displaySlot, objective));
++ for (int j = 0; j < i; ++j) {
++ DisplaySlot displayslot = adisplayslot[j];
++
++ if (this.getDisplayObjective(displayslot) == objective) {
++ list.add(new ClientboundSetDisplayObjectivePacket(displayslot, objective));
+ }
+ }
+
+- for (PlayerScoreEntry playerScoreEntry : this.listPlayerScores(objective)) {
+- list.add(
+- new ClientboundSetScorePacket(
+- playerScoreEntry.owner(),
+- objective.getName(),
+- playerScoreEntry.value(),
+- playerScoreEntry.display(),
+- playerScoreEntry.numberFormatOverride()
+- )
+- );
++ Iterator iterator = this.listPlayerScores(objective).iterator();
++
++ while (iterator.hasNext()) {
++ PlayerScoreEntry playerscoreentry = (PlayerScoreEntry) iterator.next();
++
++ list.add(new ClientboundSetScorePacket(playerscoreentry.owner(), objective.getName(), playerscoreentry.value(), playerscoreentry.display(), playerscoreentry.numberFormatOverride()));
+ }
+
+ return list;
+ }
+
+ public void startTrackingObjective(Objective objective) {
+- List<Packet<?>> startTrackingPackets = this.getStartTrackingPackets(objective);
++ List<Packet<?>> list = this.getStartTrackingPackets(objective);
++ Iterator iterator = this.server.getPlayerList().getPlayers().iterator();
+
+- for (ServerPlayer serverPlayer : this.server.getPlayerList().getPlayers()) {
+- for (Packet<?> packet : startTrackingPackets) {
+- serverPlayer.connection.send(packet);
++ while (iterator.hasNext()) {
++ 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();
++
++ entityplayer.connection.send(packet);
+ }
+ }
+
+@@ -211,11 +220,16 @@
+
+ public List<Packet<?>> getStopTrackingPackets(Objective objective) {
+ List<Packet<?>> list = Lists.newArrayList();
++
+ list.add(new ClientboundSetObjectivePacket(objective, 1));
++ DisplaySlot[] adisplayslot = DisplaySlot.values();
++ int i = adisplayslot.length;
+
+- for (DisplaySlot displaySlot : DisplaySlot.values()) {
+- if (this.getDisplayObjective(displaySlot) == objective) {
+- list.add(new ClientboundSetDisplayObjectivePacket(displaySlot, objective));
++ for (int j = 0; j < i; ++j) {
++ DisplaySlot displayslot = adisplayslot[j];
++
++ if (this.getDisplayObjective(displayslot) == objective) {
++ list.add(new ClientboundSetDisplayObjectivePacket(displayslot, objective));
+ }
+ }
+
+@@ -223,11 +237,18 @@
+ }
+
+ public void stopTrackingObjective(Objective objective) {
+- List<Packet<?>> stopTrackingPackets = this.getStopTrackingPackets(objective);
++ List<Packet<?>> list = this.getStopTrackingPackets(objective);
++ Iterator iterator = this.server.getPlayerList().getPlayers().iterator();
+
+- for (ServerPlayer serverPlayer : this.server.getPlayerList().getPlayers()) {
+- for (Packet<?> packet : stopTrackingPackets) {
+- serverPlayer.connection.send(packet);
++ while (iterator.hasNext()) {
++ 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();
++
++ entityplayer.connection.send(packet);
+ }
+ }
+
+@@ -236,32 +257,50 @@
+
+ public int getObjectiveDisplaySlotCount(Objective objective) {
+ int i = 0;
++ DisplaySlot[] adisplayslot = DisplaySlot.values();
++ int j = adisplayslot.length;
+
+- for (DisplaySlot displaySlot : DisplaySlot.values()) {
+- if (this.getDisplayObjective(displaySlot) == objective) {
+- i++;
++ for (int k = 0; k < j; ++k) {
++ DisplaySlot displayslot = adisplayslot[k];
++
++ if (this.getDisplayObjective(displayslot) == objective) {
++ ++i;
+ }
+ }
+
+ 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);
+- this.addDirtyListener(scoreboardSaveData::setDirty);
+- return scoreboardSaveData;
++ ScoreboardSaveData persistentscoreboard = new ScoreboardSaveData(this);
++
++ Objects.requireNonNull(persistentscoreboard);
++ this.addDirtyListener(persistentscoreboard::setDirty);
++ return persistentscoreboard;
+ }
+
+ private ScoreboardSaveData createData(CompoundTag tag) {
+ return this.createData().load(tag);
+ }
+
+- public static enum Method {
+- CHANGE,
+- REMOVE;
++ // 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 Action() {}
++ }
+ }