13
0
geforkt von Mirrors/Paper

Multiple Entries with Scoreboards

Dieser Commit ist enthalten in:
Cryptite 2021-09-21 18:17:33 -05:00
Ursprung 4ab8912b68
Commit 0fd1e5c650
3 geänderte Dateien mit 92 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,18 @@
--- a/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
+++ b/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
@@ -200,7 +200,7 @@
@@ -58,6 +58,11 @@
);
}
+ // Paper start - Multiple Entries with Scoreboards
+ public static ClientboundSetPlayerTeamPacket createMultiplePlayerPacket(PlayerTeam team, Collection<String> players, ClientboundSetPlayerTeamPacket.Action operation) {
+ return new ClientboundSetPlayerTeamPacket(team.getName(), operation == ClientboundSetPlayerTeamPacket.Action.ADD ? 3 : 4, Optional.empty(), players);
+ }
+ // Paper end - Multiple Entries with Scoreboards
private ClientboundSetPlayerTeamPacket(RegistryFriendlyByteBuf buf) {
this.name = buf.readUtf();
this.method = buf.readByte();
@@ -200,7 +205,7 @@
ComponentSerialization.TRUSTED_STREAM_CODEC.encode(buf, this.displayName);
buf.writeByte(this.options);
buf.writeUtf(this.nametagVisibility);

Datei anzeigen

@ -54,7 +54,29 @@
this.setDirty();
return true;
} else {
@@ -109,7 +109,7 @@
@@ -106,13 +106,43 @@
}
}
+ // Paper start - Multiple Entries with Scoreboards
+ public boolean addPlayersToTeam(java.util.Collection<String> players, PlayerTeam team) {
+ boolean anyAdded = false;
+ for (String playerName : players) {
+ if (super.addPlayerToTeam(playerName, team)) {
+ anyAdded = true;
+ }
+ }
+
+ if (anyAdded) {
+ this.broadcastAll(ClientboundSetPlayerTeamPacket.createMultiplePlayerPacket(team, players, ClientboundSetPlayerTeamPacket.Action.ADD));
+ this.setDirty();
+ return true;
+ } else {
+ return false;
+ }
+ }
+ // Paper end - Multiple Entries with Scoreboards
+
@Override
public void removePlayerFromTeam(String scoreHolderName, PlayerTeam team) {
super.removePlayerFromTeam(scoreHolderName, team);
@ -63,7 +85,21 @@
this.setDirty();
}
@@ -123,7 +123,7 @@
+ // Paper start - Multiple Entries with Scoreboards
+ public void removePlayersFromTeam(java.util.Collection<String> players, PlayerTeam team) {
+ for (String playerName : players) {
+ super.removePlayerFromTeam(playerName, team);
+ }
+
+ this.broadcastAll(ClientboundSetPlayerTeamPacket.createMultiplePlayerPacket(team, players, ClientboundSetPlayerTeamPacket.Action.REMOVE));
+ this.setDirty();
+ }
+ // Paper end - Multiple Entries with Scoreboards
+
@Override
public void onObjectiveAdded(Objective objective) {
super.onObjectiveAdded(objective);
@@ -123,7 +153,7 @@
public void onObjectiveChanged(Objective objective) {
super.onObjectiveChanged(objective);
if (this.trackedObjectives.contains(objective)) {
@ -72,7 +108,7 @@
}
this.setDirty();
@@ -142,21 +142,21 @@
@@ -142,21 +172,21 @@
@Override
public void onTeamAdded(PlayerTeam team) {
super.onTeamAdded(team);
@ -97,7 +133,7 @@
this.setDirty();
}
@@ -207,6 +207,7 @@
@@ -207,6 +237,7 @@
while (iterator.hasNext()) {
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
@ -105,7 +141,7 @@
Iterator iterator1 = list.iterator();
while (iterator1.hasNext()) {
@@ -243,6 +244,7 @@
@@ -243,6 +274,7 @@
while (iterator.hasNext()) {
ServerPlayer entityplayer = (ServerPlayer) iterator.next();
@ -113,7 +149,7 @@
Iterator iterator1 = list.iterator();
while (iterator1.hasNext()) {
@@ -287,6 +289,16 @@
@@ -287,6 +319,16 @@
return this.createData().load(nbt, registries);
}

Datei anzeigen

@ -229,6 +229,21 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
scoreboard.board.addPlayerToTeam(entry, this.team);
}
// Paper start - Multiple Entries with Scoreboards
@Override
public void addEntities(java.util.Collection<org.bukkit.entity.Entity> entities) throws IllegalStateException, IllegalArgumentException {
this.addEntries(entities.stream().map(entity -> ((org.bukkit.craftbukkit.entity.CraftEntity) entity).getHandle().getScoreboardName()).toList());
}
@Override
public void addEntries(java.util.Collection<String> entries) throws IllegalStateException, IllegalArgumentException {
Preconditions.checkArgument(entries != null, "Entries cannot be null");
CraftScoreboard scoreboard = this.checkState();
((net.minecraft.server.ServerScoreboard) scoreboard.board).addPlayersToTeam(entries, this.team);
}
// Paper end - Multiple Entries with Scoreboards
@Override
public boolean removePlayer(OfflinePlayer player) {
Preconditions.checkArgument(player != null, "OfflinePlayer cannot be null");
@ -248,6 +263,28 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
return true;
}
// Paper start - Multiple Entries with Scoreboards
@Override
public boolean removeEntities(java.util.Collection<org.bukkit.entity.Entity> entities) throws IllegalStateException, IllegalArgumentException {
return this.removeEntries(entities.stream().map(entity -> ((org.bukkit.craftbukkit.entity.CraftEntity) entity).getHandle().getScoreboardName()).toList());
}
@Override
public boolean removeEntries(java.util.Collection<String> entries) throws IllegalStateException, IllegalArgumentException {
Preconditions.checkArgument(entries != null, "Entry cannot be null");
CraftScoreboard scoreboard = this.checkState();
for (String entry : entries) {
if (this.team.getPlayers().contains(entry)) {
((net.minecraft.server.ServerScoreboard) scoreboard.board).removePlayersFromTeam(entries, this.team);
return true;
}
}
return false;
}
// Paper end - Multiple Entries with Scoreboards
@Override
public boolean hasPlayer(OfflinePlayer player) throws IllegalArgumentException, IllegalStateException {
Preconditions.checkArgument(player != null, "OfflinePlayer cannot be null");