Make Team extend ForwardingAudience (#9852)

This commit is contained in:
powercas_gamer 2023-11-04 21:50:56 +01:00 committed by GitHub
parent 43c343228e
commit 15a0de2eef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 12 deletions

View file

@ -4808,9 +4808,18 @@ index 083bb2c92a2c557e10b705b773ced97401586c3c..d5723e977d9a25701a4f387f1b26d241
/**
diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/bukkit/scoreboard/Team.java
index 7b9a7890b25ca4bd95ab81f3181288bf79ed649c..e5a38e3568148170025e05c7ba69e8615f578047 100644
index 7b9a7890b25ca4bd95ab81f3181288bf79ed649c..52e8be769d2e9b69e9833bc9a7fe39afd10c5095 100644
--- a/src/main/java/org/bukkit/scoreboard/Team.java
+++ b/src/main/java/org/bukkit/scoreboard/Team.java
@@ -12,7 +12,7 @@ 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
@@ -23,13 +23,96 @@ public interface Team {
@NotNull
String getName();

View file

@ -1229,10 +1229,10 @@ index 22b1dc5fd4d453161a5ee520072f8e8f955b3a80..a625bcab8e77b05b3341a52c708fae15
boolean isModifiable();
diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/bukkit/scoreboard/Team.java
index e5a38e3568148170025e05c7ba69e8615f578047..1bd8ba3232398d3b07c9e00cf5b36851e9a28b58 100644
index 52e8be769d2e9b69e9833bc9a7fe39afd10c5095..4d2b8e10263802432dfeac72666487f9547cd2c5 100644
--- a/src/main/java/org/bukkit/scoreboard/Team.java
+++ b/src/main/java/org/bukkit/scoreboard/Team.java
@@ -265,7 +265,7 @@ public interface Team {
@@ -265,7 +265,7 @@ public interface Team extends net.kyori.adventure.audience.ForwardingAudience {
* Gets the Set of entries on the team
*
* @return entries on the team

View file

@ -110,10 +110,10 @@ index d5723e977d9a25701a4f387f1b26d2414e0fffb8..30e2b9484cdf4c8efd02e2cda97739e3
+ // Paper end - improve scoreboard entries
}
diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/bukkit/scoreboard/Team.java
index 1bd8ba3232398d3b07c9e00cf5b36851e9a28b58..bb60f49a48282fdeae1f7b797ed6ad98b68b1e14 100644
index 4d2b8e10263802432dfeac72666487f9547cd2c5..dff76db4a4c37c760144f00c1aa8f2bcac45ba1f 100644
--- a/src/main/java/org/bukkit/scoreboard/Team.java
+++ b/src/main/java/org/bukkit/scoreboard/Team.java
@@ -295,9 +295,8 @@ public interface Team {
@@ -295,9 +295,8 @@ 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 1bd8ba3232398d3b07c9e00cf5b36851e9a28b58..bb60f49a48282fdeae1f7b797ed6ad98
void addPlayer(@NotNull OfflinePlayer player);
/**
@@ -317,9 +316,8 @@ public interface Team {
@@ -317,9 +316,8 @@ 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 1bd8ba3232398d3b07c9e00cf5b36851e9a28b58..bb60f49a48282fdeae1f7b797ed6ad98
boolean removePlayer(@NotNull OfflinePlayer player);
/**
@@ -345,9 +343,8 @@ public interface Team {
@@ -345,9 +343,8 @@ 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 1bd8ba3232398d3b07c9e00cf5b36851e9a28b58..bb60f49a48282fdeae1f7b797ed6ad98
boolean hasPlayer(@NotNull OfflinePlayer player);
/**
* Checks to see if the specified entry is a member of this team.
@@ -377,6 +374,42 @@ public interface Team {
@@ -377,6 +374,42 @@ public interface Team extends net.kyori.adventure.audience.ForwardingAudience {
*/
void setOption(@NotNull Option option, @NotNull OptionStatus status);

View file

@ -5,10 +5,10 @@ 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 bb60f49a48282fdeae1f7b797ed6ad98b68b1e14..8424fdac153f6dea76acce89f4726408d9726c41 100644
index dff76db4a4c37c760144f00c1aa8f2bcac45ba1f..cacb58d25c249e2ecd6083ed0f30d5ffb345220a 100644
--- a/src/main/java/org/bukkit/scoreboard/Team.java
+++ b/src/main/java/org/bukkit/scoreboard/Team.java
@@ -309,6 +309,60 @@ public interface Team {
@@ -309,6 +309,60 @@ public interface Team extends net.kyori.adventure.audience.ForwardingAudience {
*/
void addEntry(@NotNull String entry);
@ -69,7 +69,7 @@ index bb60f49a48282fdeae1f7b797ed6ad98b68b1e14..8424fdac153f6dea76acce89f4726408
/**
* Removes the player from this team.
*
@@ -329,6 +383,56 @@ public interface Team {
@@ -329,6 +383,56 @@ public interface Team extends net.kyori.adventure.audience.ForwardingAudience {
*/
boolean removeEntry(@NotNull String entry);

View file

@ -4828,7 +4828,7 @@ index e9cdca6d5fac186ef18167e183518ecade7b4471..3f09420ba9268ac1dc5440c073974437
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
index 4d586e1375ed8782939c9d480479e0dd981f8cbc..c0362c54d0d097ad6cd4616b3ab194e51258da1e 100644
index 4d586e1375ed8782939c9d480479e0dd981f8cbc..7900adb0b158bc17dd792dd082c338547bc1aa0a 100644
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
@@ -26,6 +26,63 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
@ -4895,6 +4895,27 @@ index 4d586e1375ed8782939c9d480479e0dd981f8cbc..c0362c54d0d097ad6cd4616b3ab194e5
@Override
public String getDisplayName() {
@@ -303,4 +360,20 @@ 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<? extends net.kyori.adventure.audience.Audience> audiences() {
+ this.checkState();
+ java.util.List<net.kyori.adventure.audience.Audience> 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 0be5b600b5701f6132b52b8928dc5926b52201f3..19a102792fab30f8f6a7364d0a9b4063d76f1489 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java