-
-
Notifications
You must be signed in to change notification settings - Fork 102
/
ScoreboardAPI.java
87 lines (71 loc) · 2.28 KB
/
ScoreboardAPI.java
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
package net.aufdemrand.denizen.utilities.scoreboard;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import net.aufdemrand.denizen.utilities.debugging.dB;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
public class ScoreboardAPI {
public static ScoreboardAPI api_instance = null;
public ScoreboardAPI() {
api_instance = this;
}
public static List<Scoreboard> scoreboards = new ArrayList<Scoreboard>();
public static ScoreboardAPI getInstance() {
return api_instance;
}
public List<Scoreboard> getScoreboards() {
return scoreboards;
}
public Scoreboard createScoreboard(String name, int priority) {
for (Scoreboard s : scoreboards) {
if (s.getName().equalsIgnoreCase(name)) {
return s;
}
}
Scoreboard s = new Scoreboard(name, priority);
scoreboards.add(s);
return s;
}
public Scoreboard getScoreboard(String name) {
dB.echoDebug(scoreboards.size() + " SBSIZE");
for (Scoreboard s : scoreboards) {
if (s.getName().equalsIgnoreCase(name)) {
return s;
}
}
return null;
}
public void updateForPlayer(Player p) {
for (Scoreboard s : scoreboards) {
s.checkIfNeedsToBeDisabledForPlayer(p);
s.checkIfNeedsToBeEnabledForPlayer(p);
}
}
public void removeScoreboard(String name) {
Scoreboard to_remove = null;
for (Scoreboard s : scoreboards) {
if (s.getName().equalsIgnoreCase(name)) {
to_remove = s;
}
}
to_remove.stopShowingAllPlayers();
scoreboards.remove(to_remove);
}
public boolean isPlayerReceivingScoreboard(Player p) {
for (Scoreboard s: scoreboards) {
if (s.hasPlayerAdded(p)) {
return true;
}
}
return false;
}
public void updateForAllPlayers() {
for (Player p : Bukkit.getOnlinePlayers()) {
updateForPlayer(p);
}
}
}