2022-01-10 06:08:55 +01:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Cryptite <cryptite@gmail.com>
|
|
|
|
Date: Tue, 21 Sep 2021 18:17:33 -0500
|
|
|
|
Subject: [PATCH] Multiple Entries with Scoreboards
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
|
2024-01-18 22:00:40 +01:00
|
|
|
index e52644010dc2cf41bbf508b16b8ec2f0003e9d0b..f06ee212528d5670fb83720c2b543f864b64e873 100644
|
2022-01-10 06:08:55 +01:00
|
|
|
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
|
|
|
|
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
|
|
|
|
@@ -42,6 +42,12 @@ public class ClientboundSetPlayerTeamPacket implements Packet<ClientGamePacketLi
|
|
|
|
return new ClientboundSetPlayerTeamPacket(team.getName(), operation == ClientboundSetPlayerTeamPacket.Action.ADD ? 3 : 4, Optional.empty(), ImmutableList.of(playerName));
|
|
|
|
}
|
|
|
|
|
2024-01-18 22:00:40 +01:00
|
|
|
+ // Paper start - Multiple Entries with Scoreboards
|
2022-01-10 06:08:55 +01:00
|
|
|
+ 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);
|
|
|
|
+ }
|
2024-01-18 22:00:40 +01:00
|
|
|
+ // Paper end - Multiple Entries with Scoreboards
|
2022-01-10 06:08:55 +01:00
|
|
|
+
|
|
|
|
public ClientboundSetPlayerTeamPacket(FriendlyByteBuf buf) {
|
|
|
|
this.name = buf.readUtf();
|
|
|
|
this.method = buf.readByte();
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ServerScoreboard.java b/src/main/java/net/minecraft/server/ServerScoreboard.java
|
2024-01-18 22:00:40 +01:00
|
|
|
index c4904b358fc2f493e6a9572a84b8110a927da208..76d67d01388ecc1af6b43212e018edc678e84d72 100644
|
2022-01-10 06:08:55 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/ServerScoreboard.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ServerScoreboard.java
|
2023-12-06 17:00:26 +01:00
|
|
|
@@ -104,6 +104,25 @@ public class ServerScoreboard extends Scoreboard {
|
2022-01-10 06:08:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-18 22:00:40 +01:00
|
|
|
+ // Paper start - Multiple Entries with Scoreboards
|
2022-01-10 06:08:55 +01:00
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+ }
|
2024-01-18 22:00:40 +01:00
|
|
|
+ // Paper end - Multiple Entries with Scoreboards
|
2022-01-10 06:08:55 +01:00
|
|
|
+
|
|
|
|
@Override
|
2023-12-06 17:00:26 +01:00
|
|
|
public void removePlayerFromTeam(String scoreHolderName, PlayerTeam team) {
|
|
|
|
super.removePlayerFromTeam(scoreHolderName, team);
|
|
|
|
@@ -111,6 +130,17 @@ public class ServerScoreboard extends Scoreboard {
|
2022-01-10 06:08:55 +01:00
|
|
|
this.setDirty();
|
|
|
|
}
|
|
|
|
|
2024-01-18 22:00:40 +01:00
|
|
|
+ // Paper start - Multiple Entries with Scoreboards
|
2022-01-10 06:08:55 +01:00
|
|
|
+ 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();
|
|
|
|
+ }
|
2024-01-18 22:00:40 +01:00
|
|
|
+ // Paper end - Multiple Entries with Scoreboards
|
2022-01-10 06:08:55 +01:00
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public void onObjectiveAdded(Objective objective) {
|
|
|
|
super.onObjectiveAdded(objective);
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
|
2024-01-18 22:00:40 +01:00
|
|
|
index 27219bf2f16aed64c78623d44c3cc84aa9f47065..2b335c750ce5f9ccc2651a8701497ca9b8f46704 100644
|
2022-01-10 06:08:55 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
|
2023-08-06 02:21:59 +02:00
|
|
|
@@ -229,6 +229,21 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
|
2023-10-27 01:34:58 +02:00
|
|
|
scoreboard.board.addPlayerToTeam(entry, this.team);
|
2022-01-10 06:08:55 +01:00
|
|
|
}
|
|
|
|
|
2024-01-18 22:00:40 +01:00
|
|
|
+ // Paper start - Multiple Entries with Scoreboards
|
2022-01-10 06:08:55 +01:00
|
|
|
+ @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 {
|
2023-06-13 01:51:45 +02:00
|
|
|
+ Preconditions.checkArgument(entries != null, "Entries cannot be null");
|
2022-01-10 06:08:55 +01:00
|
|
|
+ CraftScoreboard scoreboard = this.checkState();
|
|
|
|
+
|
|
|
|
+ ((net.minecraft.server.ServerScoreboard) scoreboard.board).addPlayersToTeam(entries, this.team);
|
|
|
|
+ }
|
2024-01-18 22:00:40 +01:00
|
|
|
+ // Paper end - Multiple Entries with Scoreboards
|
2022-01-10 06:08:55 +01:00
|
|
|
+
|
|
|
|
@Override
|
2023-08-06 02:21:59 +02:00
|
|
|
public boolean removePlayer(OfflinePlayer player) {
|
2023-06-13 01:51:45 +02:00
|
|
|
Preconditions.checkArgument(player != null, "OfflinePlayer cannot be null");
|
2023-08-06 02:21:59 +02:00
|
|
|
@@ -248,6 +263,28 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
|
2022-01-10 06:08:55 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-01-18 22:00:40 +01:00
|
|
|
+ // Paper start - Multiple Entries with Scoreboards
|
2022-01-10 06:08:55 +01:00
|
|
|
+ @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 {
|
2023-06-13 01:51:45 +02:00
|
|
|
+ Preconditions.checkArgument(entries != null, "Entry cannot be null");
|
2022-01-10 06:08:55 +01:00
|
|
|
+ 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;
|
|
|
|
+ }
|
2024-01-18 22:00:40 +01:00
|
|
|
+ // Paper end - Multiple Entries with Scoreboards
|
2022-01-10 06:08:55 +01:00
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public boolean hasPlayer(OfflinePlayer player) throws IllegalArgumentException, IllegalStateException {
|
2023-06-13 01:51:45 +02:00
|
|
|
Preconditions.checkArgument(player != null, "OfflinePlayer cannot be null");
|