+ Added way to disable the scoreboard.
This commit is contained in:
parent
197e647ece
commit
572ef9d948
@ -82,6 +82,7 @@ public enum ConfigC {
|
||||
"%A%arenaname%", "%A%players%%N/%A%maxplayers%",
|
||||
"%EIngame: %A%timeleft%" }, W.config),
|
||||
|
||||
scoreboard_enabled (true, W.config),
|
||||
scoreboard_title ("[" + BlockHunt.pdfFile.getName() + "]", W.config),
|
||||
scoreboard_timeleft ("%ATime left:", W.config),
|
||||
scoreboard_seekers ("%NSeekers:", W.config),
|
||||
|
@ -12,67 +12,70 @@ import org.bukkit.scoreboard.Scoreboard;
|
||||
|
||||
public class ScoreboardHandler {
|
||||
public static void createScoreboard(Arena arena) {
|
||||
Scoreboard board = arena.scoreboard;
|
||||
if (board.getObjective(arena.arenaName) != null) {
|
||||
updateScoreboard(arena);
|
||||
return;
|
||||
}
|
||||
|
||||
Objective object = board.registerNewObjective(arena.arenaName, "dummy");
|
||||
object.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
object.setDisplayName(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_title)));
|
||||
Score timeleft = object
|
||||
.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_timeleft))));
|
||||
timeleft.setScore(arena.timer);
|
||||
Score seekers = object
|
||||
.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_seekers))));
|
||||
seekers.setScore(arena.seekers.size());
|
||||
Score hiders = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||
.replaceAll((String) W.config.get(ConfigC.scoreboard_hiders))));
|
||||
hiders.setScore(arena.playersInArena.size() - arena.seekers.size());
|
||||
if (arena.gameState == ArenaState.INGAME) {
|
||||
for (Player pl : arena.playersInArena) {
|
||||
pl.setScoreboard(board);
|
||||
if ((Boolean) W.config.get(ConfigC.scoreboard_enabled) == true) {
|
||||
Scoreboard board = arena.scoreboard;
|
||||
if (board.getObjective(arena.arenaName) != null) {
|
||||
updateScoreboard(arena);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
for (Player pl : arena.playersInArena) {
|
||||
pl.setScoreboard(Bukkit.getScoreboardManager()
|
||||
.getNewScoreboard());
|
||||
|
||||
Objective object = board.registerNewObjective(arena.arenaName,
|
||||
"dummy");
|
||||
object.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
object.setDisplayName(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_title)));
|
||||
Score timeleft = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_timeleft))));
|
||||
timeleft.setScore(arena.timer);
|
||||
Score seekers = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_seekers))));
|
||||
seekers.setScore(arena.seekers.size());
|
||||
Score hiders = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_hiders))));
|
||||
hiders.setScore(arena.playersInArena.size() - arena.seekers.size());
|
||||
if (arena.gameState == ArenaState.INGAME) {
|
||||
for (Player pl : arena.playersInArena) {
|
||||
pl.setScoreboard(board);
|
||||
}
|
||||
} else {
|
||||
for (Player pl : arena.playersInArena) {
|
||||
pl.setScoreboard(Bukkit.getScoreboardManager()
|
||||
.getNewScoreboard());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateScoreboard(Arena arena) {
|
||||
Scoreboard board = arena.scoreboard;
|
||||
Objective object = board.getObjective(DisplaySlot.SIDEBAR);
|
||||
object.setDisplayName(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_title)));
|
||||
Score timeleft = object
|
||||
.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_timeleft))));
|
||||
timeleft.setScore(arena.timer);
|
||||
Score seekers = object
|
||||
.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_seekers))));
|
||||
seekers.setScore(arena.seekers.size());
|
||||
Score hiders = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||
.replaceAll((String) W.config.get(ConfigC.scoreboard_hiders))));
|
||||
hiders.setScore(arena.playersInArena.size() - arena.seekers.size());
|
||||
if (arena.gameState == ArenaState.INGAME) {
|
||||
for (Player pl : arena.playersInArena) {
|
||||
pl.setScoreboard(board);
|
||||
}
|
||||
} else {
|
||||
for (Player pl : arena.playersInArena) {
|
||||
pl.setScoreboard(Bukkit.getScoreboardManager()
|
||||
.getNewScoreboard());
|
||||
if ((Boolean) W.config.get(ConfigC.scoreboard_enabled) == true) {
|
||||
Scoreboard board = arena.scoreboard;
|
||||
Objective object = board.getObjective(DisplaySlot.SIDEBAR);
|
||||
object.setDisplayName(MessageM.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_title)));
|
||||
Score timeleft = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_timeleft))));
|
||||
timeleft.setScore(arena.timer);
|
||||
Score seekers = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_seekers))));
|
||||
seekers.setScore(arena.seekers.size());
|
||||
Score hiders = object.getScore(Bukkit.getOfflinePlayer(MessageM
|
||||
.replaceAll((String) W.config
|
||||
.get(ConfigC.scoreboard_hiders))));
|
||||
hiders.setScore(arena.playersInArena.size() - arena.seekers.size());
|
||||
if (arena.gameState == ArenaState.INGAME) {
|
||||
for (Player pl : arena.playersInArena) {
|
||||
pl.setScoreboard(board);
|
||||
}
|
||||
} else {
|
||||
for (Player pl : arena.playersInArena) {
|
||||
pl.setScoreboard(Bukkit.getScoreboardManager()
|
||||
.getNewScoreboard());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user