From 126c1576c4966a99a7d6f27d9dd546307445f83d Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Sun, 16 Mar 2014 16:13:40 -0500 Subject: [PATCH] Add the jail name to the scoreboard's title. --- src/main/java/com/graywolf336/jail/JailMain.java | 2 +- src/main/java/com/graywolf336/jail/PrisonerManager.java | 2 +- src/main/java/com/graywolf336/jail/ScoreBoardManager.java | 7 ++++--- .../com/graywolf336/jail/listeners/PlayerListener.java | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/graywolf336/jail/JailMain.java b/src/main/java/com/graywolf336/jail/JailMain.java index 56d5de0..9eccda6 100644 --- a/src/main/java/com/graywolf336/jail/JailMain.java +++ b/src/main/java/com/graywolf336/jail/JailMain.java @@ -163,7 +163,7 @@ public class JailMain extends JavaPlugin { for(Jail j : jm.getJails()) { for(Prisoner p : j.getAllPrisoners()) { if(getServer().getPlayerExact(p.getName()) != null) { - this.sbm.addScoreBoard(getServer().getPlayerExact(p.getName()), p); + this.sbm.addScoreBoard(getServer().getPlayerExact(p.getName()), j, p); } } } diff --git a/src/main/java/com/graywolf336/jail/PrisonerManager.java b/src/main/java/com/graywolf336/jail/PrisonerManager.java index be368e3..fcd6951 100644 --- a/src/main/java/com/graywolf336/jail/PrisonerManager.java +++ b/src/main/java/com/graywolf336/jail/PrisonerManager.java @@ -269,7 +269,7 @@ public class PrisonerManager { //Add the scoreboard to them if it is enabled if(pl.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) { - pl.getScoreBoardManager().addScoreBoard(player, prisoner); + pl.getScoreBoardManager().addScoreBoard(player, jail, prisoner); } //Call our custom event for when a prisoner is actually jailed. diff --git a/src/main/java/com/graywolf336/jail/ScoreBoardManager.java b/src/main/java/com/graywolf336/jail/ScoreBoardManager.java index b30a55a..18a7288 100644 --- a/src/main/java/com/graywolf336/jail/ScoreBoardManager.java +++ b/src/main/java/com/graywolf336/jail/ScoreBoardManager.java @@ -2,6 +2,7 @@ package com.graywolf336.jail; import java.util.HashMap; +import org.bukkit.ChatColor; import org.bukkit.OfflinePlayer; import org.bukkit.entity.Player; import org.bukkit.scoreboard.DisplaySlot; @@ -41,12 +42,12 @@ public class ScoreBoardManager { * @param player of whom to add the scoreboard to. * @param pris data for the provided prisoner */ - public void addScoreBoard(Player player, Prisoner pris) { + public void addScoreBoard(Player player, Jail j, Prisoner pris) { if(!boards.containsKey(player.getName())) { boards.put(player.getName(), man.getNewScoreboard()); Objective o = boards.get(player.getName()).registerNewObjective("test", "dummy"); o.setDisplaySlot(DisplaySlot.SIDEBAR); - o.setDisplayName(Util.getColorfulMessage(pl.getConfig().getString(Settings.SCOREBOARDTITLE.getPath()))); + o.setDisplayName(Util.getColorfulMessage(pl.getConfig().getString(Settings.SCOREBOARDTITLE.getPath()) + ChatColor.WHITE + "" + ChatColor.ITALIC + " (" + j.getName() + ")")); o.getScore(time).setScore(pris.getRemainingTimeInMinutesInt()); player.setScoreboard(boards.get(player.getName())); }else { @@ -85,7 +86,7 @@ public class ScoreBoardManager { for(Jail j : pl.getJailManager().getJails()) { for(Prisoner p : j.getAllPrisoners()) { if(pl.getServer().getPlayerExact(p.getName()) != null) { - addScoreBoard(pl.getServer().getPlayerExact(p.getName()), p); + addScoreBoard(pl.getServer().getPlayerExact(p.getName()), j, p); } } } diff --git a/src/main/java/com/graywolf336/jail/listeners/PlayerListener.java b/src/main/java/com/graywolf336/jail/listeners/PlayerListener.java index 29a0da7..11d0ba3 100644 --- a/src/main/java/com/graywolf336/jail/listeners/PlayerListener.java +++ b/src/main/java/com/graywolf336/jail/listeners/PlayerListener.java @@ -124,7 +124,7 @@ public class PlayerListener implements Listener { //Add the scoreboard to them if it is enabled if(pl.getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) { - pl.getScoreBoardManager().addScoreBoard(event.getPlayer(), p); + pl.getScoreBoardManager().addScoreBoard(event.getPlayer(), j, p); } //if we are ignoring a prisoner's sleeping state, then let's set that