2015-02-28 12:36:22 +01:00
|
|
|
From 008bf408d502227c1979f95c858ee21b41bae6cc Mon Sep 17 00:00:00 2001
|
2014-07-21 22:46:54 +02:00
|
|
|
From: md_5 <git@md-5.net>
|
|
|
|
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
|
2015-02-28 12:36:22 +01:00
|
|
|
index 342d4af..6b7233e 100644
|
2014-07-21 22:46:54 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftTeam.java
|
2015-02-28 12:36:22 +01:00
|
|
|
@@ -115,6 +115,19 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
|
2014-07-21 22:46:54 +02:00
|
|
|
return players.build();
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Spigot start
|
|
|
|
+ @Override
|
|
|
|
+ public Set<String> getEntries() throws IllegalStateException {
|
|
|
|
+ CraftScoreboard scoreboard = checkState();
|
|
|
|
+
|
|
|
|
+ ImmutableSet.Builder<String> 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();
|
|
|
|
|
2015-02-28 12:36:22 +01:00
|
|
|
@@ -123,28 +136,50 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
|
2014-07-21 22:46:54 +02:00
|
|
|
|
|
|
|
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
|
2015-02-28 12:36:22 +01:00
|
|
|
@@ -211,27 +246,6 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
|
2015-01-25 15:44:52 +01:00
|
|
|
final CraftTeam other = (CraftTeam) obj;
|
|
|
|
return !(this.team != other.team && (this.team == null || !this.team.equals(other.team)));
|
2014-11-28 02:17:45 +01:00
|
|
|
}
|
|
|
|
-
|
|
|
|
- // Spigot start
|
|
|
|
- @Override
|
|
|
|
- public Set<String> getEntries() throws IllegalStateException {
|
|
|
|
- throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void addEntry(String entry) throws IllegalStateException, IllegalArgumentException {
|
|
|
|
- throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public boolean removeEntry(String entry) throws IllegalStateException, IllegalArgumentException {
|
|
|
|
- throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public boolean hasEntry(String entry) throws IllegalArgumentException, IllegalStateException {
|
|
|
|
- throw new UnsupportedOperationException("Not supported yet.");
|
|
|
|
- }
|
2015-01-25 15:44:52 +01:00
|
|
|
// Spigot end
|
|
|
|
|
2014-11-28 02:17:45 +01:00
|
|
|
}
|
2014-07-21 22:46:54 +02:00
|
|
|
--
|
2014-11-28 02:17:45 +01:00
|
|
|
2.1.0
|
2014-07-21 22:46:54 +02:00
|
|
|
|