From 5cfbe38b3186191354fc36a5f7d623f0eda4ffff Mon Sep 17 00:00:00 2001 From: powercas_gamer Date: Sat, 4 Nov 2023 21:50:56 +0100 Subject: [PATCH] Make Team extend ForwardingAudience (#9852) --- patches/api/Adventure.patch | 9 ++++++++ patches/api/Fix-upstream-javadocs.patch | 2 +- patches/api/Improve-scoreboard-entries.patch | 8 +++---- .../Multiple-Entries-with-Scoreboards.patch | 4 ++-- patches/server/Adventure.patch | 21 +++++++++++++++++++ 5 files changed, 37 insertions(+), 7 deletions(-) diff --git a/patches/api/Adventure.patch b/patches/api/Adventure.patch index e745798d3b..78ee8119ff 100644 --- a/patches/api/Adventure.patch +++ b/patches/api/Adventure.patch @@ -4811,6 +4811,15 @@ diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/b index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/scoreboard/Team.java +++ b/src/main/java/org/bukkit/scoreboard/Team.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.Nullable; + * properties. This team is only relevant to the display of the associated + * {@link #getScoreboard() scoreboard}. + */ +-public interface Team { ++public interface Team extends net.kyori.adventure.audience.ForwardingAudience { // Paper - Make Team extend ForwardingAudience + + /** + * Gets the name of this Team @@ -0,0 +0,0 @@ public interface Team { @NotNull String getName(); diff --git a/patches/api/Fix-upstream-javadocs.patch b/patches/api/Fix-upstream-javadocs.patch index d10ef5ad01..670a11e52d 100644 --- a/patches/api/Fix-upstream-javadocs.patch +++ b/patches/api/Fix-upstream-javadocs.patch @@ -1232,7 +1232,7 @@ diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/b index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/scoreboard/Team.java +++ b/src/main/java/org/bukkit/scoreboard/Team.java -@@ -0,0 +0,0 @@ public interface Team { +@@ -0,0 +0,0 @@ public interface Team extends net.kyori.adventure.audience.ForwardingAudience { * Gets the Set of entries on the team * * @return entries on the team diff --git a/patches/api/Improve-scoreboard-entries.patch b/patches/api/Improve-scoreboard-entries.patch index b17bfb0bc8..8b20a11595 100644 --- a/patches/api/Improve-scoreboard-entries.patch +++ b/patches/api/Improve-scoreboard-entries.patch @@ -113,7 +113,7 @@ diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/b index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/scoreboard/Team.java +++ b/src/main/java/org/bukkit/scoreboard/Team.java -@@ -0,0 +0,0 @@ public interface Team { +@@ -0,0 +0,0 @@ public interface Team extends net.kyori.adventure.audience.ForwardingAudience { * @param player the player to add * @throws IllegalStateException if this team has been unregistered * @see #addEntry(String) @@ -124,7 +124,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 void addPlayer(@NotNull OfflinePlayer player); /** -@@ -0,0 +0,0 @@ public interface Team { +@@ -0,0 +0,0 @@ public interface Team extends net.kyori.adventure.audience.ForwardingAudience { * @return if the player was on this team * @throws IllegalStateException if this team has been unregistered * @see #removeEntry(String) @@ -135,7 +135,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 boolean removePlayer(@NotNull OfflinePlayer player); /** -@@ -0,0 +0,0 @@ public interface Team { +@@ -0,0 +0,0 @@ public interface Team extends net.kyori.adventure.audience.ForwardingAudience { * @return true if the player is a member of this team * @throws IllegalStateException if this team has been unregistered * @see #hasEntry(String) @@ -146,7 +146,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 boolean hasPlayer(@NotNull OfflinePlayer player); /** * Checks to see if the specified entry is a member of this team. -@@ -0,0 +0,0 @@ public interface Team { +@@ -0,0 +0,0 @@ public interface Team extends net.kyori.adventure.audience.ForwardingAudience { */ void setOption(@NotNull Option option, @NotNull OptionStatus status); diff --git a/patches/api/Multiple-Entries-with-Scoreboards.patch b/patches/api/Multiple-Entries-with-Scoreboards.patch index 4672db75fc..df75a454e6 100644 --- a/patches/api/Multiple-Entries-with-Scoreboards.patch +++ b/patches/api/Multiple-Entries-with-Scoreboards.patch @@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/b index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/scoreboard/Team.java +++ b/src/main/java/org/bukkit/scoreboard/Team.java -@@ -0,0 +0,0 @@ public interface Team { +@@ -0,0 +0,0 @@ public interface Team extends net.kyori.adventure.audience.ForwardingAudience { */ void addEntry(@NotNull String entry); @@ -69,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** * Removes the player from this team. * -@@ -0,0 +0,0 @@ public interface Team { +@@ -0,0 +0,0 @@ public interface Team extends net.kyori.adventure.audience.ForwardingAudience { */ boolean removeEntry(@NotNull String entry); diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index cc75a3abc2..c982448901 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -4895,6 +4895,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public String getDisplayName() { +@@ -0,0 +0,0 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { + return !(this.team != other.team && (this.team == null || !this.team.equals(other.team))); + } + ++ // Paper start - make Team extend ForwardingAudience ++ @Override ++ public @org.jetbrains.annotations.NotNull Iterable audiences() { ++ this.checkState(); ++ java.util.List audiences = new java.util.ArrayList<>(); ++ for (String playerName : this.team.getPlayers()) { ++ org.bukkit.entity.Player player = Bukkit.getPlayerExact(playerName); ++ if (player != null) { ++ audiences.add(player); ++ } ++ } ++ ++ return audiences; ++ } ++ // Paper end - make Team extend ForwardingAudience ++ + } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java