+ Added way to disable the scoreboard.

This commit is contained in:
Steffion 2013-09-22 15:54:36 +02:00
parent 197e647ece
commit 572ef9d948
2 changed files with 59 additions and 55 deletions

View File

@ -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),

View File

@ -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());
}
}
}
}