PaperMC/paper-server/nms-patches/net/minecraft/server/ScoreboardServer.patch
CraftBukkit/Spigot 8398e12b34 Update to Minecraft 1.20.3
By: md_5 <git@md-5.net>
2023-12-06 03:40:00 +11:00

132 lines
6.9 KiB
Diff

--- a/net/minecraft/server/ScoreboardServer.java
+++ b/net/minecraft/server/ScoreboardServer.java
@@ -40,7 +40,7 @@
protected void onScoreChanged(ScoreHolder scoreholder, ScoreboardObjective scoreboardobjective, ScoreboardScore scoreboardscore) {
super.onScoreChanged(scoreholder, scoreboardobjective, scoreboardscore);
if (this.trackedObjectives.contains(scoreboardobjective)) {
- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardScore(scoreholder.getScoreboardName(), scoreboardobjective.getName(), scoreboardscore.value(), scoreboardscore.display(), scoreboardscore.numberFormat()));
+ this.broadcastAll(new PacketPlayOutScoreboardScore(scoreholder.getScoreboardName(), scoreboardobjective.getName(), scoreboardscore.value(), scoreboardscore.display(), scoreboardscore.numberFormat())); // CraftBukkit
}
this.setDirty();
@@ -55,7 +55,7 @@
@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();
}
@@ -63,7 +63,7 @@
public void onPlayerScoreRemoved(ScoreHolder scoreholder, ScoreboardObjective scoreboardobjective) {
super.onPlayerScoreRemoved(scoreholder, scoreboardobjective);
if (this.trackedObjectives.contains(scoreboardobjective)) {
- this.server.getPlayerList().broadcastAll(new ClientboundResetScorePacket(scoreholder.getScoreboardName(), scoreboardobjective.getName()));
+ this.broadcastAll(new ClientboundResetScorePacket(scoreholder.getScoreboardName(), scoreboardobjective.getName())); // CraftBukkit
}
this.setDirty();
@@ -76,7 +76,7 @@
super.setDisplayObjective(displayslot, scoreboardobjective);
if (scoreboardobjective1 != scoreboardobjective && scoreboardobjective1 != null) {
if (this.getObjectiveDisplaySlotCount(scoreboardobjective1) > 0) {
- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardDisplayObjective(displayslot, scoreboardobjective));
+ this.broadcastAll(new PacketPlayOutScoreboardDisplayObjective(displayslot, scoreboardobjective)); // CraftBukkit
} else {
this.stopTrackingObjective(scoreboardobjective1);
}
@@ -84,7 +84,7 @@
if (scoreboardobjective != null) {
if (this.trackedObjectives.contains(scoreboardobjective)) {
- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardDisplayObjective(displayslot, scoreboardobjective));
+ this.broadcastAll(new PacketPlayOutScoreboardDisplayObjective(displayslot, scoreboardobjective)); // CraftBukkit
} else {
this.startTrackingObjective(scoreboardobjective);
}
@@ -96,7 +96,7 @@
@Override
public boolean addPlayerToTeam(String s, ScoreboardTeam scoreboardteam) {
if (super.addPlayerToTeam(s, scoreboardteam)) {
- this.server.getPlayerList().broadcastAll(PacketPlayOutScoreboardTeam.createPlayerPacket(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.ADD));
+ this.broadcastAll(PacketPlayOutScoreboardTeam.createPlayerPacket(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.ADD)); // CraftBukkit
this.setDirty();
return true;
} else {
@@ -107,7 +107,7 @@
@Override
public void removePlayerFromTeam(String s, ScoreboardTeam scoreboardteam) {
super.removePlayerFromTeam(s, scoreboardteam);
- this.server.getPlayerList().broadcastAll(PacketPlayOutScoreboardTeam.createPlayerPacket(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.REMOVE));
+ this.broadcastAll(PacketPlayOutScoreboardTeam.createPlayerPacket(scoreboardteam, s, PacketPlayOutScoreboardTeam.a.REMOVE)); // CraftBukkit
this.setDirty();
}
@@ -121,7 +121,7 @@
public void onObjectiveChanged(ScoreboardObjective scoreboardobjective) {
super.onObjectiveChanged(scoreboardobjective);
if (this.trackedObjectives.contains(scoreboardobjective)) {
- this.server.getPlayerList().broadcastAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2));
+ this.broadcastAll(new PacketPlayOutScoreboardObjective(scoreboardobjective, 2)); // CraftBukkit
}
this.setDirty();
@@ -140,21 +140,21 @@
@Override
public void onTeamAdded(ScoreboardTeam scoreboardteam) {
super.onTeamAdded(scoreboardteam);
- this.server.getPlayerList().broadcastAll(PacketPlayOutScoreboardTeam.createAddOrModifyPacket(scoreboardteam, true));
+ this.broadcastAll(PacketPlayOutScoreboardTeam.createAddOrModifyPacket(scoreboardteam, true)); // CraftBukkit
this.setDirty();
}
@Override
public void onTeamChanged(ScoreboardTeam scoreboardteam) {
super.onTeamChanged(scoreboardteam);
- this.server.getPlayerList().broadcastAll(PacketPlayOutScoreboardTeam.createAddOrModifyPacket(scoreboardteam, false));
+ this.broadcastAll(PacketPlayOutScoreboardTeam.createAddOrModifyPacket(scoreboardteam, false)); // CraftBukkit
this.setDirty();
}
@Override
public void onTeamRemoved(ScoreboardTeam scoreboardteam) {
super.onTeamRemoved(scoreboardteam);
- this.server.getPlayerList().broadcastAll(PacketPlayOutScoreboardTeam.createRemovePacket(scoreboardteam));
+ this.broadcastAll(PacketPlayOutScoreboardTeam.createRemovePacket(scoreboardteam)); // CraftBukkit
this.setDirty();
}
@@ -205,6 +205,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
+ if (entityplayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board
Iterator iterator1 = list.iterator();
while (iterator1.hasNext()) {
@@ -241,6 +242,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
+ if (entityplayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board
Iterator iterator1 = list.iterator();
while (iterator1.hasNext()) {
@@ -285,6 +287,16 @@
return this.createData().load(nbttagcompound);
}
+ // CraftBukkit start - Send to players
+ private void broadcastAll(Packet packet) {
+ for (EntityPlayer entityplayer : (List<EntityPlayer>) this.server.getPlayerList().players) {
+ if (entityplayer.getBukkitEntity().getScoreboard().getHandle() == this) {
+ entityplayer.connection.send(packet);
+ }
+ }
+ }
+ // CraftBukkit end
+
public static enum Action {
CHANGE, REMOVE;