From 64a7507a12612db2a71ca4aadb2461644f48a452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=81=AA=E8=81=AA?= <178666380@qq.com> Date: Wed, 28 Jun 2017 08:27:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=AB=98=E7=89=88=E6=9C=ACAP?= =?UTF-8?q?I=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- patches/org/bukkit/scoreboard/Team.java.patch | 52 +++++++++++++++++++ .../craftbukkit/scoreboard/CraftTeam.java | 27 ++++++++-- 2 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 patches/org/bukkit/scoreboard/Team.java.patch diff --git a/patches/org/bukkit/scoreboard/Team.java.patch b/patches/org/bukkit/scoreboard/Team.java.patch new file mode 100644 index 0000000..c279057 --- /dev/null +++ b/patches/org/bukkit/scoreboard/Team.java.patch @@ -0,0 +1,52 @@ +--- ../src-base/minecraft/org/bukkit/scoreboard/Team.java ++++ ../src-work/minecraft/org/bukkit/scoreboard/Team.java +@@ -146,6 +146,17 @@ + void addPlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException; + + /** ++ * This puts the specified entry onto this team for the scoreboard. ++ *

++ * This will remove the entry from any other team on the scoreboard. ++ * ++ * @param entry the entry to add ++ * @throws IllegalArgumentException if entry is null ++ * @throws IllegalStateException if this team has been unregistered ++ */ ++ void addEntry(String entry) throws IllegalStateException, IllegalArgumentException; ++ ++ /** + * Removes the player from this team. + * + * @param player the player to remove +@@ -156,6 +167,16 @@ + boolean removePlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException; + + /** ++ * Removes the entry from this team. ++ * ++ * @param entry the entry to remove ++ * @throws IllegalArgumentException if entry is null ++ * @throws IllegalStateException if this team has been unregistered ++ * @return if the entry was a part of this team ++ */ ++ boolean removeEntry(String entry) throws IllegalStateException, IllegalArgumentException; ++ ++ /** + * Unregisters this team from the Scoreboard + * + * @throws IllegalStateException if this team has been unregistered +@@ -171,4 +192,14 @@ + * @throws IllegalStateException if this team has been unregistered + */ + boolean hasPlayer(OfflinePlayer player) throws IllegalArgumentException, IllegalStateException; ++ ++ /** ++ * Checks to see if the specified entry is a member of this team. ++ * ++ * @param entry the entry to search for ++ * @return true if the entry is a member of this team ++ * @throws IllegalArgumentException if entry is null ++ * @throws IllegalStateException if this team has been unregistered ++ */ ++ boolean hasEntry(String entry) throws IllegalArgumentException, IllegalStateException; + } diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java index 4cee541..072d239 100644 --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java +++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java @@ -109,28 +109,45 @@ final class CraftTeam extends CraftScoreboardComponent implements Team { public void addPlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException { Validate.notNull(player, "OfflinePlayer cannot be null"); + this.addEntry(player.getName()); + } + + @Override + public void addEntry(String player) throws IllegalStateException,IllegalArgumentException{ + Validate.notNull(player, "PlayerName cannot be null"); CraftScoreboard scoreboard = checkState(); - scoreboard.board.func_151392_a(player.getName(), team.getRegisteredName()); + scoreboard.board.func_151392_a(player, team.getRegisteredName()); } public boolean removePlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException { - Validate.notNull(player, "OfflinePlayer cannot be null"); + return this.removeEntry(player.getName()); + } + + @Override + public boolean removeEntry(String player) throws IllegalStateException,IllegalArgumentException{ + Validate.notNull(player, "PlayerName cannot be null"); CraftScoreboard scoreboard = checkState(); - if (!team.getMembershipCollection().contains(player.getName())) { + if (!team.getMembershipCollection().contains(player)) { return false; } - scoreboard.board.removePlayerFromTeam(player.getName(), team); + scoreboard.board.removePlayerFromTeam(player, team); return true; } public boolean hasPlayer(OfflinePlayer player) throws IllegalArgumentException, IllegalStateException { Validate.notNull(player, "OfflinePlayer cannot be null"); + return this.hasEntry(player.getName()); + } + + @Override + public boolean hasEntry(String entry) throws IllegalArgumentException,IllegalStateException{ + Validate.notNull(entry, "PlayerName cannot be null"); CraftScoreboard scoreboard = checkState(); - return team.getMembershipCollection().contains(player.getName()); + return team.getMembershipCollection().contains(entry); } @Override