3
0

增加高版本API方法

This commit is contained in:
聪聪 2017-06-28 08:27:25 +08:00
parent 05b874f281
commit 64a7507a12
2 changed files with 74 additions and 5 deletions

View File

@ -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.
+ * <p>
+ * 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;
}

View File

@ -109,28 +109,45 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
public void addPlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException { public void addPlayer(OfflinePlayer player) throws IllegalStateException, IllegalArgumentException {
Validate.notNull(player, "OfflinePlayer cannot be null"); 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(); 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 { 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(); CraftScoreboard scoreboard = checkState();
if (!team.getMembershipCollection().contains(player.getName())) { if (!team.getMembershipCollection().contains(player)) {
return false; return false;
} }
scoreboard.board.removePlayerFromTeam(player.getName(), team); scoreboard.board.removePlayerFromTeam(player, team);
return true; return true;
} }
public boolean hasPlayer(OfflinePlayer player) throws IllegalArgumentException, IllegalStateException { public boolean hasPlayer(OfflinePlayer player) throws IllegalArgumentException, IllegalStateException {
Validate.notNull(player, "OfflinePlayer cannot be null"); 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(); CraftScoreboard scoreboard = checkState();
return team.getMembershipCollection().contains(player.getName()); return team.getMembershipCollection().contains(entry);
} }
@Override @Override