Fixed the NPE on Spigot builds pointed out in #2417.
This commit is contained in:
QuarkTheAwesome 2015-01-21 09:18:58 +11:00
parent 385fe1bb05
commit 38bd37e4fa

View File

@ -370,25 +370,34 @@ public class ScoreboardManager {
*/
public static Objective getPowerLevelObjective() {
if (!Config.getInstance().getPowerLevelTagsEnabled()) {
try {
Objective objective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE);
if (objective != null) {
objective.unregister();
mcMMO.p.debug("Removed leftover scoreboard objects from Power Level Tags.");
}
} catch (NullPointerException e) {
//It's already null
}
return null;
}
try {
Objective powerObjective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE);
if (powerObjective == null) {
powerObjective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().registerNewObjective(POWER_OBJECTIVE, "dummy");
powerObjective.setDisplayName(TAG_POWER_LEVEL);
powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME);
}
return powerObjective;
} catch (NullPointerException e) {
Objective powerObjective;
powerObjective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().registerNewObjective(POWER_OBJECTIVE, "dummy");
powerObjective.setDisplayName(TAG_POWER_LEVEL);
powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME);
return powerObjective;
}
}
private static void changeScoreboard(ScoreboardWrapper wrapper, int displayTime) {