From 8e5d96309f459c29316add4e9e0dbec2a25540f9 Mon Sep 17 00:00:00 2001 From: Eric Stokes Date: Sat, 10 Dec 2011 17:34:29 -0700 Subject: [PATCH] Load locale before erring, add more generic locale messages. --- .../MultiverseCore/MultiverseCore.java | 22 +++++++++---------- .../localization/MultiverseMessage.java | 4 +++- src/main/resources/localization/en.yml | 1 + 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index f583f416..aef82cd0 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -21,6 +21,7 @@ import com.onarandombox.MultiverseCore.listeners.MVPluginListener; import com.onarandombox.MultiverseCore.listeners.MVWeatherListener; import com.onarandombox.MultiverseCore.localization.MessageProvider; import com.onarandombox.MultiverseCore.localization.MessageProviding; +import com.onarandombox.MultiverseCore.localization.MultiverseMessage; import com.onarandombox.MultiverseCore.localization.SimpleMessageProvider; import com.onarandombox.MultiverseCore.utils.*; import com.pneumaticraft.commandhandler.CommandHandler; @@ -198,19 +199,21 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag // this function will be called every time a plugin registers a new envtype with MV // Setup & Load our Configuration files. loadConfigs(); - if (this.multiverseConfig != null) { - this.worldManager.loadDefaultWorlds(); - this.worldManager.loadWorlds(true); - } else { - this.log(Level.SEVERE, "Your configs were not loaded. Very little will function in Multiverse."); - } - this.anchorManager.loadAnchors(); try { this.messageProvider.setLocale(new Locale(multiverseConfig.getString("locale", "en"))); } catch (IllegalArgumentException e) { this.log(Level.SEVERE, e.getMessage()); this.getServer().getPluginManager().disablePlugin(this); + return; } + if (this.multiverseConfig != null) { + this.worldManager.loadDefaultWorlds(); + this.worldManager.loadWorlds(true); + } else { + this.log(Level.SEVERE, this.getMessageProvider().getMessage(MultiverseMessage.ERROR_LOAD)); + } + this.anchorManager.loadAnchors(); + } private boolean validateAllpay() { @@ -408,7 +411,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag @Override public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) { if (!this.isEnabled()) { - sender.sendMessage("This plugin is Disabled!"); + sender.sendMessage(this.getMessageProvider().getMessage(MultiverseMessage.GENERIC_PLUGIN_DISABLED)); return true; } ArrayList allArgs = new ArrayList(Arrays.asList(args)); @@ -430,13 +433,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core, Messag public static void staticLog(Level level, String msg) { if (level == Level.FINE && GlobalDebug >= 1) { staticDebugLog(Level.INFO, msg); - return; } else if (level == Level.FINER && GlobalDebug >= 2) { staticDebugLog(Level.INFO, msg); - return; } else if (level == Level.FINEST && GlobalDebug >= 3) { staticDebugLog(Level.INFO, msg); - return; } else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) { log.log(level, tag + " " + msg); debugLog.log(level, tag + " " + msg); diff --git a/src/main/java/com/onarandombox/MultiverseCore/localization/MultiverseMessage.java b/src/main/java/com/onarandombox/MultiverseCore/localization/MultiverseMessage.java index 96ad5f7b..c028a4cd 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/localization/MultiverseMessage.java +++ b/src/main/java/com/onarandombox/MultiverseCore/localization/MultiverseMessage.java @@ -12,7 +12,9 @@ public enum MultiverseMessage { GENERIC_SORRY("Sorry..."), GENERIC_OF("of"), GENERIC_PAGE("Page"), - GENERIC_UNLOADED("UNLOADED"), ERROR_LOAD("Your configs were not loaded. Very little will function in Multiverse."); + GENERIC_UNLOADED("UNLOADED"), + ERROR_LOAD("Your configs were not loaded. Very little will function in Multiverse."), + GENERIC_PLUGIN_DISABLED("This plugin is Disabled!"); private final String def; diff --git a/src/main/resources/localization/en.yml b/src/main/resources/localization/en.yml index dde608e2..eaa8ce84 100644 --- a/src/main/resources/localization/en.yml +++ b/src/main/resources/localization/en.yml @@ -5,6 +5,7 @@ GENERIC_SORRY: 'Sorry...' GENERIC_PAGE: 'Page' GENERIC_OF: 'of' GENERIC_UNLOADED: 'UNLOADED' +GENERIC_PLUGIN_DISABLED: 'This plugin is Disabled!' # Errors ERROR_LOAD: 'Your configs were not loaded. Very little will function in Multiverse.'