Files
OldSliceMC/patches/api/0333-Multiple-Entries-with-Scoreboards.patch
Cryptite e66a1b38e5 Add/Remove multiple entries to Scoreboard Team
It is a common pattern to fill a team up with several entries. Unfortunately, each single entry addition sends a ScoreboardTeam packet out which can be unnecessarily chatty. This patch just adds the option to set a collection of entries on a scoreboard team which can get bundled into a single packet.

Likely not a significant optimization, but hey, every little bit helps.
2021-09-21 15:09:39 -05:00

59 lines
2.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Cryptite <cryptite@gmail.com>
Date: Tue, 21 Sep 2021 15:06:50 -0500
Subject: [PATCH] Multiple Entries with Scoreboards
diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/bukkit/scoreboard/Team.java
index d5b39fb4fc16a342b5661e08df1506858168d20d..1fc332a4b1da9bb2214a714a6c01e1f3249f3df8 100644
--- a/src/main/java/org/bukkit/scoreboard/Team.java
+++ b/src/main/java/org/bukkit/scoreboard/Team.java
@@ -1,5 +1,6 @@
package org.bukkit.scoreboard;
+import java.util.Collection;
import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
@@ -317,6 +318,20 @@ public interface Team {
*/
void addEntry(@NotNull String entry) throws IllegalStateException, IllegalArgumentException;
+ // Paper start
+ /**
+ * This puts a collection of entries onto this team for the scoreboard which results in one
+ * packet for the updates rather than a packet-per-entry.
+ * <p>
+ * Entries on other teams will be removed from their respective teams.
+ *
+ * @param entries the entries to add
+ * @throws IllegalArgumentException if entries are null
+ * @throws IllegalStateException if this team has been unregistered
+ */
+ void addEntries(@NotNull Collection<String> entries) throws IllegalStateException, IllegalArgumentException;
+ // Paper end
+
/**
* Removes the player from this team.
*
@@ -340,6 +355,19 @@ public interface Team {
*/
boolean removeEntry(@NotNull String entry) throws IllegalStateException, IllegalArgumentException;
+ // Paper start
+ /**
+ * Removes a collection of entries from this team which results in one
+ * packet for the updates rather than a packet-per-entry.
+ *
+ * @param entries the entries to remove
+ * @return if any of the entries were a part of this team
+ * @throws IllegalArgumentException if entry is null
+ * @throws IllegalStateException if this team has been unregistered
+ */
+ boolean removeEntries(@NotNull Collection<String> entries) throws IllegalStateException, IllegalArgumentException;
+ // Paper end
+
/**
* Unregisters this team from the Scoreboard
*