Add null check before toggling scoreboard.

This commit is contained in:
drtshock 2015-03-09 23:44:34 -05:00
parent ffa7872145
commit c3452c97aa
2 changed files with 9 additions and 2 deletions

View File

@ -38,8 +38,13 @@ public class CmdSB extends FCommand {
@Override
public void perform() {
boolean toggle = toggle(me.getPlayer().getUniqueId());
FScoreboard.get(fme).setSidebarVisibility(toggle);
FScoreboard board = FScoreboard.get(fme);
if(board == null) {
me.sendMessage(TL.COMMAND_TOGGLESB_DISABLED.toString());
} else {
me.sendMessage(TL.TOGGLE_SB.toString().replace("{value}", String.valueOf(toggle)));
board.setSidebarVisibility(toggle);
}
}
/**

View File

@ -473,6 +473,8 @@ public enum TL {
COMMAND_TOGGLEALLIANCECHAT_IGNORE("Alliance chat is now ignored"),
COMMAND_TOGGLEALLIANCECHAT_UNIGNORE("Alliance chat is no longer ignored"),
COMMAND_TOGGLESB_DISABLED("You can't toggle scoreboards while they are disabled."),
COMMAND_TOP_DESCRIPTION("Sort Factions to see the top of some criteria."),
COMMAND_TOP_TOP("Top Factions by %s. Page %d/%d"),
COMMAND_TOP_LINE("%d. &6%s: &c%s"), // Rank. Faction: Value