Fix ScoreboardManager NPE and added locale messages relating to scoreboards

This commit is contained in:
nossr50 2021-12-27 10:46:56 -08:00
parent 61388f46f1
commit ddc9a69f4b
4 changed files with 22 additions and 3 deletions

View File

@ -1,6 +1,9 @@
Version 2.1.207 Version 2.1.207
Added unicode support to locale files (no more UTF-16 codes) Temporarily rolling required Java version back to 16
Temporarily rolling required Java version back to 16 until 1.18 is stable and everyone can migrate to it safely Added unicode (UTF-8) support to locale files (no more UTF-16 codes needed)
Added locale key 'Scoreboard.Disabled' to en_US
Added locale key 'Scoreboard.NotSetupYet' to en_US
Fixed a bug where Salvage sent messages even though the event was cancelled (Thanks TheBusyBiscuit)
Version 2.1.206 Version 2.1.206
Fixed a memory leak involving Herbalism under specific circumstances Fixed a memory leak involving Herbalism under specific circumstances

View File

@ -23,6 +23,16 @@ public class McscoreboardCommand implements TabExecutor {
return true; return true;
} }
if(!mcMMO.p.getGeneralConfig().getScoreboardsEnabled()) {
sender.sendMessage(LocaleLoader.getString("Scoreboard.Disabled"));
return true;
}
if(!ScoreboardManager.isPlayerBoardSetup(sender.getName())) {
sender.sendMessage(LocaleLoader.getString("Scoreboard.NotSetupYet"));
return true;
}
switch (args.length) { switch (args.length) {
case 1: case 1:
if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) { if (args[0].equalsIgnoreCase("clear") || args[0].equalsIgnoreCase("reset")) {

View File

@ -574,6 +574,10 @@ public class ScoreboardManager {
PLAYER_SCOREBOARDS.get(playerName).showBoardAndScheduleRevert(seconds * Misc.TICK_CONVERSION_FACTOR); PLAYER_SCOREBOARDS.get(playerName).showBoardAndScheduleRevert(seconds * Misc.TICK_CONVERSION_FACTOR);
} }
public static boolean isPlayerBoardSetup(@NotNull String playerName) {
return PLAYER_SCOREBOARDS.get(playerName) != null;
}
public static @Nullable ScoreboardWrapper makeNewScoreboard(Player player) { public static @Nullable ScoreboardWrapper makeNewScoreboard(Player player) {
if(getScoreboardManager() == null) if(getScoreboardManager() == null)
return null; return null;

View File

@ -1143,3 +1143,5 @@ Chat.Spy.Party=&6[&eSPY&6-&a{2}&6] &r{0} &b\u2192 &r{1}
Broadcasts.LevelUpMilestone=&6(&amcMMO&6) {0}&7 has reached level &a{1}&7 in &3{2}&7! Broadcasts.LevelUpMilestone=&6(&amcMMO&6) {0}&7 has reached level &a{1}&7 in &3{2}&7!
Broadcasts.PowerLevelUpMilestone=&6(&amcMMO&6) {0}&7 has reached a Power level of &a{1}&7! Broadcasts.PowerLevelUpMilestone=&6(&amcMMO&6) {0}&7 has reached a Power level of &a{1}&7!
Scoreboard.Recovery=Attempting to recover mcMMO scoreboard... Scoreboard.Recovery=Attempting to recover mcMMO scoreboard...
Scoreboard.Disabled=The mcMMO scoreboards for this server are disabled, this setting is found in mcMMO/config.yml
Scoreboard.NotSetupYet=Your mcMMO scoreboard has not been setup yet, try again later.