mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-07 19:30:34 +01:00
c0936a71bd
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 01aa02eb PR-858: Add LivingEntity#playHurtAnimation() 9421320f PR-884: Refinements to new ban API for improved compatibility and correctness 37a60b45 SPIGOT-6455, SPIGOT-7030, PR-750: Improve ban API 4eeb174b All smithing inventories are now the new smithing inventory f2bb168e PR-880: Add methods to get/set FallingBlock CancelDrop e7a807fa PR-879: Add Player#sendHealthUpdate() 692b8e96 SPIGOT-7370: Remove float value conversion in plugin.yml 2d033390 SPIGOT-7403: Add direct API for waxed signs 16a08373 PR-876: Add missing Raider API and 'no action ticks' CraftBukkit Changes: b60a95c8c PR-1189: Add LivingEntity#playHurtAnimation() 95c335c63 PR-1226: Fix VehicleEnterEvent not being called for certain entities 0a0fc3bee PR-1227: Refinements to new ban API for improved compatibility and correctness 0d0b1e5dc Revert bad change to PathfinderGoalSit causing all cats to sit 648196070 SPIGOT-6455, SPIGOT-7030, PR-1054: Improve ban API 31fe848d6 All smithing inventories are now the new smithing inventory 9a919a143 SPIGOT-7416: SmithItemEvent not firing in Smithing Table 9f64f0d22 PR-1221: Add methods to get/set FallingBlock CancelDrop 3be9ac171 PR-1220: Add Player#sendHealthUpdate() c1279f775 PR-1209: Clean up various patches c432e4397 Fix Raider#setCelebrating() implementation 504d96665 SPIGOT-7403: Add direct API for waxed signs c68c1f1b3 PR-1216: Add missing Raider API and 'no action ticks' 85b89c3dd Increase outdated build delay Spigot Changes: 9ebce8af Rebuild patches 64b565e6 Rebuild patches
127 lines
6.0 KiB
Diff
127 lines
6.0 KiB
Diff
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
|
|
index ee37ec0de1ca969144824427ae42b0c81434a1b4..4ebe22ac20f1a98694cc3bec570ef5bbf06f00aa 100644
|
|
--- 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));
|
|
}
|
|
|
|
+ // Paper start
|
|
+ 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
|
|
+
|
|
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
|
|
index 610d312b9c8f6c8d1f102e8ba2fe9fc2cc3e98c5..3a4a0727ad44322e3ba85512cd077808dab080b7 100644
|
|
--- a/src/main/java/net/minecraft/server/ServerScoreboard.java
|
|
+++ b/src/main/java/net/minecraft/server/ServerScoreboard.java
|
|
@@ -92,6 +92,25 @@ public class ServerScoreboard extends Scoreboard {
|
|
}
|
|
}
|
|
|
|
+ // Paper start
|
|
+ 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
|
|
+
|
|
@Override
|
|
public void removePlayerFromTeam(String playerName, PlayerTeam team) {
|
|
super.removePlayerFromTeam(playerName, team);
|
|
@@ -99,6 +118,17 @@ public class ServerScoreboard extends Scoreboard {
|
|
this.setDirty();
|
|
}
|
|
|
|
+ // Paper start
|
|
+ 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
|
|
+
|
|
@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
|
|
index 47031a6f1b7e261bb034968f83c0c496b89d1361..7098b77fe4275e39694ed7d8fb031b9397302b9f 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
|
|
@@ -234,6 +234,21 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
|
|
scoreboard.board.addPlayerToTeam(entry, team);
|
|
}
|
|
|
|
+ // Paper start
|
|
+ @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
|
|
+
|
|
@Override
|
|
public boolean removePlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException {
|
|
Preconditions.checkArgument(player != null, "OfflinePlayer cannot be null");
|
|
@@ -253,6 +268,28 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
|
|
return true;
|
|
}
|
|
|
|
+ // Paper start
|
|
+ @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
|
|
+
|
|
@Override
|
|
public boolean hasPlayer(OfflinePlayer player) throws IllegalArgumentException, IllegalStateException {
|
|
Preconditions.checkArgument(player != null, "OfflinePlayer cannot be null");
|