aboutsummaryrefslogtreecommitdiffhomepage
path: root/CraftBukkit-Patches/0129-Expand-team-API-to-allow-arbitrary-strings.patch
blob: 2b66585dfae4a0fb95da2a85bb7cda1ef3efb4e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
From 9119dfe5e378281bc33dc8b374f87543fd81fcff 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 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<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
-- 
1.9.1