mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-05 02:10:30 +01:00
19972e09b8
5a0150f586ed3eb15fe6f1f596d1a5a7d806f0f9 Fix ITEM_BREAK e6a3911057bd94d8bd7021cbb4923fb84fb106d1 Upstream merge d1cdcf8d4c3639f956474f02ed662517cffbe23e Remove old patch 068df64aeee368377e1673667bffc7a6dcf90554 Rebuild all patches
116 lines
4.2 KiB
Diff
116 lines
4.2 KiB
Diff
From af4cca3fdb0ff0af9e22638500b9cf24f39d6f9c Mon Sep 17 00:00:00 2001
|
|
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
|
|
index e38d109..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<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();
|
|
|
|
@@ -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
|
|
@@ -142,26 +177,4 @@ final class CraftTeam extends CraftScoreboardComponent implements Team {
|
|
scoreboard.teams.remove(team.getName());
|
|
setUnregistered();
|
|
}
|
|
-
|
|
- // 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.");
|
|
- }
|
|
- // Spigot end
|
|
}
|
|
--
|
|
2.1.0
|
|
|