Archiviert
13
0

Fix some team color docs and added hasColor (#7602)

Dieser Commit ist enthalten in:
Jake Potrebic 2022-04-23 18:37:10 -07:00 committet von GitHub
Ursprung 5b85ee37e2
Commit 4dc78ae8b9
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
7 geänderte Dateien mit 46 neuen und 30 gelöschten Zeilen

Datei anzeigen

@ -4052,10 +4052,10 @@ index 5c855dbd0da895392f7a6e92cdc90782baf614ad..1ada91d790abedbc9b3aeb6e96467a0d
/** /**
diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/bukkit/scoreboard/Team.java diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/bukkit/scoreboard/Team.java
index 0db7fe1b9fe5621ceed3f4f046691e359f5949dd..d5b39fb4fc16a342b5661e08df1506858168d20d 100644 index 0db7fe1b9fe5621ceed3f4f046691e359f5949dd..07a9fa68075a2c5f5a4a7519976b506526d95ca0 100644
--- a/src/main/java/org/bukkit/scoreboard/Team.java --- a/src/main/java/org/bukkit/scoreboard/Team.java
+++ b/src/main/java/org/bukkit/scoreboard/Team.java +++ b/src/main/java/org/bukkit/scoreboard/Team.java
@@ -22,14 +22,93 @@ public interface Team { @@ -22,14 +22,102 @@ public interface Team {
*/ */
@NotNull @NotNull
String getName() throws IllegalStateException; String getName() throws IllegalStateException;
@ -4115,13 +4115,23 @@ index 0db7fe1b9fe5621ceed3f4f046691e359f5949dd..d5b39fb4fc16a342b5661e08df150685
+ void suffix(@Nullable net.kyori.adventure.text.Component suffix) throws IllegalStateException, IllegalArgumentException; + void suffix(@Nullable net.kyori.adventure.text.Component suffix) throws IllegalStateException, IllegalArgumentException;
+ +
+ /** + /**
+ * Checks if the team has a color specified
+ *
+ * @return true if it has a <b>color</b>
+ * @throws IllegalStateException if this team has been unregistered
+ */
+ boolean hasColor();
+
+ /**
+ * Gets the color of the team. + * Gets the color of the team.
+ * <br> + * <br>
+ * This only sets the team outline, other occurrences of colors such as in + * This only sets the team outline, other occurrences of colors such as in
+ * names are handled by prefixes / suffixes. + * names are handled by prefixes / suffixes.
+ * + *
+ * @return team color, defaults to {@link ChatColor#RESET} + * @return team color
+ * @throws IllegalStateException if this team has been unregistered + * @throws IllegalStateException if this team has been unregistered
+ * @throws IllegalStateException if the team doesn't have a color
+ * @see #hasColor()
+ */ + */
+ @NotNull net.kyori.adventure.text.format.TextColor color() throws IllegalStateException; + @NotNull net.kyori.adventure.text.format.TextColor color() throws IllegalStateException;
+ +
@ -4131,8 +4141,7 @@ index 0db7fe1b9fe5621ceed3f4f046691e359f5949dd..d5b39fb4fc16a342b5661e08df150685
+ * This only sets the team outline, other occurrences of colors such as in + * This only sets the team outline, other occurrences of colors such as in
+ * names are handled by prefixes / suffixes. + * names are handled by prefixes / suffixes.
+ * + *
+ * @param color new color, must be non-null. Use {@link ChatColor#RESET} for + * @param color new color, null for no color
+ * no color
+ */ + */
+ void color(@Nullable net.kyori.adventure.text.format.NamedTextColor color); + void color(@Nullable net.kyori.adventure.text.format.NamedTextColor color);
+ // Paper end + // Paper end
@ -4149,7 +4158,7 @@ index 0db7fe1b9fe5621ceed3f4f046691e359f5949dd..d5b39fb4fc16a342b5661e08df150685
String getDisplayName() throws IllegalStateException; String getDisplayName() throws IllegalStateException;
/** /**
@@ -39,7 +118,9 @@ public interface Team { @@ -39,7 +127,9 @@ public interface Team {
* @throws IllegalArgumentException if displayName is longer than 128 * @throws IllegalArgumentException if displayName is longer than 128
* characters. * characters.
* @throws IllegalStateException if this team has been unregistered * @throws IllegalStateException if this team has been unregistered
@ -4159,7 +4168,7 @@ index 0db7fe1b9fe5621ceed3f4f046691e359f5949dd..d5b39fb4fc16a342b5661e08df150685
void setDisplayName(@NotNull String displayName) throws IllegalStateException, IllegalArgumentException; void setDisplayName(@NotNull String displayName) throws IllegalStateException, IllegalArgumentException;
/** /**
@@ -47,8 +128,10 @@ public interface Team { @@ -47,8 +137,10 @@ public interface Team {
* *
* @return Team prefix * @return Team prefix
* @throws IllegalStateException if this team has been unregistered * @throws IllegalStateException if this team has been unregistered
@ -4170,7 +4179,7 @@ index 0db7fe1b9fe5621ceed3f4f046691e359f5949dd..d5b39fb4fc16a342b5661e08df150685
String getPrefix() throws IllegalStateException; String getPrefix() throws IllegalStateException;
/** /**
@@ -59,7 +142,9 @@ public interface Team { @@ -59,7 +151,9 @@ public interface Team {
* @throws IllegalArgumentException if prefix is longer than 64 * @throws IllegalArgumentException if prefix is longer than 64
* characters * characters
* @throws IllegalStateException if this team has been unregistered * @throws IllegalStateException if this team has been unregistered
@ -4180,7 +4189,7 @@ index 0db7fe1b9fe5621ceed3f4f046691e359f5949dd..d5b39fb4fc16a342b5661e08df150685
void setPrefix(@NotNull String prefix) throws IllegalStateException, IllegalArgumentException; void setPrefix(@NotNull String prefix) throws IllegalStateException, IllegalArgumentException;
/** /**
@@ -67,8 +152,10 @@ public interface Team { @@ -67,8 +161,10 @@ public interface Team {
* *
* @return the team's current suffix * @return the team's current suffix
* @throws IllegalStateException if this team has been unregistered * @throws IllegalStateException if this team has been unregistered
@ -4191,7 +4200,7 @@ index 0db7fe1b9fe5621ceed3f4f046691e359f5949dd..d5b39fb4fc16a342b5661e08df150685
String getSuffix() throws IllegalStateException; String getSuffix() throws IllegalStateException;
/** /**
@@ -79,7 +166,9 @@ public interface Team { @@ -79,7 +175,9 @@ public interface Team {
* @throws IllegalArgumentException if suffix is longer than 64 * @throws IllegalArgumentException if suffix is longer than 64
* characters * characters
* @throws IllegalStateException if this team has been unregistered * @throws IllegalStateException if this team has been unregistered
@ -4201,7 +4210,7 @@ index 0db7fe1b9fe5621ceed3f4f046691e359f5949dd..d5b39fb4fc16a342b5661e08df150685
void setSuffix(@NotNull String suffix) throws IllegalStateException, IllegalArgumentException; void setSuffix(@NotNull String suffix) throws IllegalStateException, IllegalArgumentException;
/** /**
@@ -90,8 +179,10 @@ public interface Team { @@ -90,8 +188,10 @@ public interface Team {
* *
* @return team color, defaults to {@link ChatColor#RESET} * @return team color, defaults to {@link ChatColor#RESET}
* @throws IllegalStateException if this team has been unregistered * @throws IllegalStateException if this team has been unregistered
@ -4212,7 +4221,7 @@ index 0db7fe1b9fe5621ceed3f4f046691e359f5949dd..d5b39fb4fc16a342b5661e08df150685
ChatColor getColor() throws IllegalStateException; ChatColor getColor() throws IllegalStateException;
/** /**
@@ -102,7 +193,9 @@ public interface Team { @@ -102,7 +202,9 @@ public interface Team {
* *
* @param color new color, must be non-null. Use {@link ChatColor#RESET} for * @param color new color, must be non-null. Use {@link ChatColor#RESET} for
* no color * no color

Datei anzeigen

@ -110,10 +110,10 @@ index 1ada91d790abedbc9b3aeb6e96467a0d78560f15..fc3456bb79f2fe1504359455b937c162
+ // Paper end + // Paper end
} }
diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/bukkit/scoreboard/Team.java diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/bukkit/scoreboard/Team.java
index d5b39fb4fc16a342b5661e08df1506858168d20d..2b93692204a74ea0def513a54ddf77a40c64d3d2 100644 index 07a9fa68075a2c5f5a4a7519976b506526d95ca0..51205a71d243195fdf35515374a1e9ef5df26bc0 100644
--- a/src/main/java/org/bukkit/scoreboard/Team.java --- a/src/main/java/org/bukkit/scoreboard/Team.java
+++ b/src/main/java/org/bukkit/scoreboard/Team.java +++ b/src/main/java/org/bukkit/scoreboard/Team.java
@@ -301,9 +301,8 @@ public interface Team { @@ -310,9 +310,8 @@ public interface Team {
* @throws IllegalArgumentException if player is null * @throws IllegalArgumentException if player is null
* @throws IllegalStateException if this team has been unregistered * @throws IllegalStateException if this team has been unregistered
* @see #addEntry(String) * @see #addEntry(String)
@ -124,7 +124,7 @@ index d5b39fb4fc16a342b5661e08df1506858168d20d..2b93692204a74ea0def513a54ddf77a4
void addPlayer(@NotNull OfflinePlayer player) throws IllegalStateException, IllegalArgumentException; void addPlayer(@NotNull OfflinePlayer player) throws IllegalStateException, IllegalArgumentException;
/** /**
@@ -325,9 +324,8 @@ public interface Team { @@ -334,9 +333,8 @@ public interface Team {
* @throws IllegalArgumentException if player is null * @throws IllegalArgumentException if player is null
* @throws IllegalStateException if this team has been unregistered * @throws IllegalStateException if this team has been unregistered
* @see #removeEntry(String) * @see #removeEntry(String)
@ -135,7 +135,7 @@ index d5b39fb4fc16a342b5661e08df1506858168d20d..2b93692204a74ea0def513a54ddf77a4
boolean removePlayer(@NotNull OfflinePlayer player) throws IllegalStateException, IllegalArgumentException; boolean removePlayer(@NotNull OfflinePlayer player) throws IllegalStateException, IllegalArgumentException;
/** /**
@@ -355,9 +353,8 @@ public interface Team { @@ -364,9 +362,8 @@ public interface Team {
* @throws IllegalArgumentException if player is null * @throws IllegalArgumentException if player is null
* @throws IllegalStateException if this team has been unregistered * @throws IllegalStateException if this team has been unregistered
* @see #hasEntry(String) * @see #hasEntry(String)
@ -146,7 +146,7 @@ index d5b39fb4fc16a342b5661e08df1506858168d20d..2b93692204a74ea0def513a54ddf77a4
boolean hasPlayer(@NotNull OfflinePlayer player) throws IllegalArgumentException, IllegalStateException; boolean hasPlayer(@NotNull OfflinePlayer player) throws IllegalArgumentException, IllegalStateException;
/** /**
* Checks to see if the specified entry is a member of this team. * Checks to see if the specified entry is a member of this team.
@@ -388,6 +385,42 @@ public interface Team { @@ -397,6 +394,42 @@ public interface Team {
*/ */
void setOption(@NotNull Option option, @NotNull OptionStatus status) throws IllegalStateException; void setOption(@NotNull Option option, @NotNull OptionStatus status) throws IllegalStateException;

Datei anzeigen

@ -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 diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/bukkit/scoreboard/Team.java
index 2b93692204a74ea0def513a54ddf77a40c64d3d2..04c8cc55a2fe19c888aba842775cc66648dddb0c 100644 index 51205a71d243195fdf35515374a1e9ef5df26bc0..0f5c49d41c9460da0ba913b4ca8bef375f2c23df 100644
--- a/src/main/java/org/bukkit/scoreboard/Team.java --- a/src/main/java/org/bukkit/scoreboard/Team.java
+++ b/src/main/java/org/bukkit/scoreboard/Team.java +++ b/src/main/java/org/bukkit/scoreboard/Team.java
@@ -316,6 +316,60 @@ public interface Team { @@ -325,6 +325,60 @@ public interface Team {
*/ */
void addEntry(@NotNull String entry) throws IllegalStateException, IllegalArgumentException; void addEntry(@NotNull String entry) throws IllegalStateException, IllegalArgumentException;
@ -69,7 +69,7 @@ index 2b93692204a74ea0def513a54ddf77a40c64d3d2..04c8cc55a2fe19c888aba842775cc666
/** /**
* Removes the player from this team. * Removes the player from this team.
* *
@@ -338,6 +392,56 @@ public interface Team { @@ -347,6 +401,56 @@ public interface Team {
*/ */
boolean removeEntry(@NotNull String entry) throws IllegalStateException, IllegalArgumentException; boolean removeEntry(@NotNull String entry) throws IllegalStateException, IllegalArgumentException;

Datei anzeigen

@ -3385,10 +3385,10 @@ index afc059755ae3e7b1c0a4cf3c6b8f32ce13cc458d..5f2af880619e01a03e05258ae1f9fa58
@Override @Override
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
index 81f16dc1ed6e102af298600db75cab21a09bc00f..f86776aa42bd5520f8aaeaa46bb93ec4d5b4e27d 100644 index 81f16dc1ed6e102af298600db75cab21a09bc00f..df1288e2e89716bba5ef73d2cdeb9a567f46a297 100644
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java +++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
@@ -28,6 +28,55 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { @@ -28,6 +28,62 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
return this.team.getName(); return this.team.getName();
} }
@ -3427,6 +3427,11 @@ index 81f16dc1ed6e102af298600db75cab21a09bc00f..f86776aa42bd5520f8aaeaa46bb93ec4
+ team.setPlayerSuffix(io.papermc.paper.adventure.PaperAdventure.asVanilla(suffix)); + team.setPlayerSuffix(io.papermc.paper.adventure.PaperAdventure.asVanilla(suffix));
+ } + }
+ @Override + @Override
+ public boolean hasColor() {
+ CraftScoreboard scoreboard = checkState();
+ return this.team.getColor().getColor() != null;
+ }
+ @Override
+ public net.kyori.adventure.text.format.TextColor color() throws IllegalStateException { + public net.kyori.adventure.text.format.TextColor color() throws IllegalStateException {
+ CraftScoreboard scoreboard = checkState(); + CraftScoreboard scoreboard = checkState();
+ if (team.getColor().getColor() == null) throw new IllegalStateException("Team colors must have hex values"); + if (team.getColor().getColor() == null) throw new IllegalStateException("Team colors must have hex values");
@ -3436,8 +3441,10 @@ index 81f16dc1ed6e102af298600db75cab21a09bc00f..f86776aa42bd5520f8aaeaa46bb93ec4
+ } + }
+ @Override + @Override
+ public void color(net.kyori.adventure.text.format.NamedTextColor color) { + public void color(net.kyori.adventure.text.format.NamedTextColor color) {
+ if (color == null) color = net.kyori.adventure.text.format.NamedTextColor.WHITE;
+ CraftScoreboard scoreboard = checkState(); + CraftScoreboard scoreboard = checkState();
+ if (color == null) {
+ this.team.setColor(net.minecraft.ChatFormatting.RESET);
+ }
+ team.setColor(io.papermc.paper.adventure.PaperAdventure.asVanilla(color)); + team.setColor(io.papermc.paper.adventure.PaperAdventure.asVanilla(color));
+ } + }
+ // Paper end + // Paper end

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Fix CraftTeam null check
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
index f86776aa42bd5520f8aaeaa46bb93ec4d5b4e27d..2b87a652798cb632fe76bf20e9e7f8cb8bfb3b7b 100644 index df1288e2e89716bba5ef73d2cdeb9a567f46a297..af4ab4be3722d3349f7f71da062dee493cd2aafe 100644
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java +++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
@@ -253,7 +253,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { @@ -260,7 +260,7 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
@Override @Override
public boolean hasEntry(String entry) throws IllegalArgumentException, IllegalStateException { public boolean hasEntry(String entry) throws IllegalArgumentException, IllegalStateException {

Datei anzeigen

@ -52,10 +52,10 @@ index 944080939ceaf2db8bcd7d3c01f4b97440e35cc1..0102c475b6e49777c1e24c32e5eff299
+ // Paper end + // Paper end
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
index 2b87a652798cb632fe76bf20e9e7f8cb8bfb3b7b..47f2e8824fff51f4271e7aa61e233d57e3ca2942 100644 index af4ab4be3722d3349f7f71da062dee493cd2aafe..d1844550bafa381a6dd88702dabef6de39be0907 100644
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java +++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
@@ -302,6 +302,26 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { @@ -309,6 +309,26 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
} }
} }

Datei anzeigen

@ -70,10 +70,10 @@ index 610d312b9c8f6c8d1f102e8ba2fe9fc2cc3e98c5..3a4a0727ad44322e3ba85512cd077808
public void onObjectiveAdded(Objective objective) { public void onObjectiveAdded(Objective objective) {
super.onObjectiveAdded(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 diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
index 47f2e8824fff51f4271e7aa61e233d57e3ca2942..be5e4c2f3c552e0438ed1cc660e411c41fd13df7 100644 index d1844550bafa381a6dd88702dabef6de39be0907..d3d9641862f4746469bca946ef6d89a88f15698b 100644
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java +++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
@@ -226,6 +226,21 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { @@ -233,6 +233,21 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
scoreboard.board.addPlayerToTeam(entry, team); scoreboard.board.addPlayerToTeam(entry, team);
} }
@ -95,7 +95,7 @@ index 47f2e8824fff51f4271e7aa61e233d57e3ca2942..be5e4c2f3c552e0438ed1cc660e411c4
@Override @Override
public boolean removePlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException { public boolean removePlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException {
Validate.notNull(player, "OfflinePlayer cannot be null"); Validate.notNull(player, "OfflinePlayer cannot be null");
@@ -245,6 +260,28 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { @@ -252,6 +267,28 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
return true; return true;
} }