From b2c227e89c4410b8a93d77d0d6b845f42781827a Mon Sep 17 00:00:00 2001 From: md_5 Date: Thu, 17 Apr 2014 19:22:33 +1000 Subject: [PATCH] Expand team API to allow arbitrary strings. --- ...-team-API-to-allow-arbitrary-strings.patch | 75 ++++++++++++++++ ...-team-API-to-allow-arbitrary-strings.patch | 88 +++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 Bukkit-Patches/0026-Expand-team-API-to-allow-arbitrary-strings.patch create mode 100644 CraftBukkit-Patches/0143-Expand-team-API-to-allow-arbitrary-strings.patch diff --git a/Bukkit-Patches/0026-Expand-team-API-to-allow-arbitrary-strings.patch b/Bukkit-Patches/0026-Expand-team-API-to-allow-arbitrary-strings.patch new file mode 100644 index 0000000..8adb870 --- /dev/null +++ b/Bukkit-Patches/0026-Expand-team-API-to-allow-arbitrary-strings.patch @@ -0,0 +1,75 @@ +From 8bfe38430d6e27b6d5d7343162c47f9bb9636566 Mon Sep 17 00:00:00 2001 +From: md_5 +Date: Thu, 17 Apr 2014 19:22:26 +1000 +Subject: [PATCH] Expand team API to allow arbitrary strings. + + +diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/bukkit/scoreboard/Team.java +index 50c6f76..b90b9c3 100644 +--- a/src/main/java/org/bukkit/scoreboard/Team.java ++++ b/src/main/java/org/bukkit/scoreboard/Team.java +@@ -118,6 +118,15 @@ public interface Team { + */ + Set getPlayers() throws IllegalStateException; + ++ // Spigot start ++ /** ++ * Same as the player method, but with an arbitrary string. ++ * ++ * @see #getPlayers() ++ */ ++ Set getEntries() throws IllegalStateException; ++ // Spigot End ++ + /** + * Gets the size of the team + * +@@ -145,6 +154,15 @@ public interface Team { + */ + void addPlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException; + ++ // Spigot start ++ /** ++ * Same as the player method, but with an arbitrary string. ++ * ++ * @see #addPlayer(org.bukkit.OfflinePlayer) ++ */ ++ void addEntry(String entry) throws IllegalStateException, IllegalArgumentException; ++ // Spigot end ++ + /** + * Removes the player from this team. + * +@@ -155,6 +173,15 @@ public interface Team { + */ + boolean removePlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException; + ++ // Spigot start ++ /** ++ * Same as the player method, but with an arbitrary string. ++ * ++ * @see #removePlayer(org.bukkit.OfflinePlayer) ++ */ ++ boolean removeEntry(String entry) throws IllegalStateException, IllegalArgumentException; ++ // Spigot end ++ + /** + * Unregisters this team from the Scoreboard + * +@@ -171,4 +198,13 @@ public interface Team { + * @throws IllegalStateException if this team has been unregistered + */ + boolean hasPlayer(OfflinePlayer player) throws IllegalArgumentException, IllegalStateException; ++ ++ // Spigot start ++ /** ++ * Same as the player method, but with an arbitrary string. ++ * ++ * @see #hasPlayer(org.bukkit.OfflinePlayer) ++ */ ++ boolean hasEntry(String entry) throws IllegalArgumentException,IllegalStateException; ++ // Spigot end + } +-- +1.8.3.2 + diff --git a/CraftBukkit-Patches/0143-Expand-team-API-to-allow-arbitrary-strings.patch b/CraftBukkit-Patches/0143-Expand-team-API-to-allow-arbitrary-strings.patch new file mode 100644 index 0000000..a96cca0 --- /dev/null +++ b/CraftBukkit-Patches/0143-Expand-team-API-to-allow-arbitrary-strings.patch @@ -0,0 +1,88 @@ +From 3444f11224082b3bafcb91dfa3327946dd128a19 Mon Sep 17 00:00:00 2001 +From: md_5 +Date: Thu, 17 Apr 2014 19:22:22 +1000 +Subject: [PATCH] Expand team API to allow arbitrary strings. + + +diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java +index 8a640d3..a1864a5 100644 +--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java ++++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java +@@ -102,6 +102,19 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { + return players.build(); + } + ++ // Spigot start ++ @Override ++ public Set getEntries() throws IllegalStateException { ++ CraftScoreboard scoreboard = checkState(); ++ ++ ImmutableSet.Builder entries = ImmutableSet.builder(); ++ for (Object o : team.getPlayerNameSet()){ ++ entries.add(o.toString()); ++ } ++ return entries.build(); ++ } ++ // Spigot end ++ + public int getSize() throws IllegalStateException { + CraftScoreboard scoreboard = checkState(); + +@@ -110,28 +123,50 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { + + public void addPlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException { + Validate.notNull(player, "OfflinePlayer cannot be null"); ++ // Spigot Start ++ addEntry(player.getName()); ++ } ++ ++ public void addEntry(String entry) throws IllegalStateException, IllegalArgumentException { ++ Validate.notNull(entry, "Entry cannot be null"); + CraftScoreboard scoreboard = checkState(); + +- scoreboard.board.addPlayerToTeam(player.getName(), team.getName()); ++ scoreboard.board.addPlayerToTeam(entry, team.getName()); ++ // Spigot end + } + + public boolean removePlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException { + Validate.notNull(player, "OfflinePlayer cannot be null"); ++ // Spigot start ++ return removeEntry(player.getName()); ++ } ++ ++ public boolean removeEntry(String entry) throws IllegalStateException, IllegalArgumentException { ++ Validate.notNull(entry, "Entry cannot be null"); + CraftScoreboard scoreboard = checkState(); + +- if (!team.getPlayerNameSet().contains(player.getName())) { ++ if (!team.getPlayerNameSet().contains(entry)) { + return false; + } + +- scoreboard.board.removePlayerFromTeam(player.getName(), team); ++ scoreboard.board.removePlayerFromTeam(entry, team); ++ // Spigot end + return true; + } + + public boolean hasPlayer(OfflinePlayer player) throws IllegalArgumentException, IllegalStateException { + Validate.notNull(player, "OfflinePlayer cannot be null"); ++ // Spigot start ++ return hasEntry(player.getName()); ++ } ++ ++ public boolean hasEntry(String entry) throws IllegalArgumentException, IllegalStateException { ++ Validate.notNull("Entry cannot be null"); ++ + CraftScoreboard scoreboard = checkState(); + +- return team.getPlayerNameSet().contains(player.getName()); ++ return team.getPlayerNameSet().contains(entry); ++ // Spigot end + } + + @Override +-- +1.8.3.2 +