From f940e1e3595eb2ef409cd6cc2c8d4f5506714729 Mon Sep 17 00:00:00 2001 From: asofold Date: Sun, 20 Jan 2013 05:59:46 +0100 Subject: [PATCH] More to the order of things. --- .../neatmonster/nocheatplus/NoCheatPlus.java | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/NoCheatPlus.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/NoCheatPlus.java index ffc22f64..3319bd22 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/NoCheatPlus.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/NoCheatPlus.java @@ -445,24 +445,19 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI { TickTask.cancel(); TickTask.reset(); - // Reset MCAccess. - mcAccess = null; - // Read the configuration files. ConfigManager.init(this); // Setup file logger. StaticLogFile.setupLogger(new File(getDataFolder(), ConfigManager.getConfigFile().getString(ConfPaths.LOGGING_FILENAME))); - // Set up BlockProperties. - BlockProperties.init(getMCAccess()); + final ConfigFile config = ConfigManager.getConfigFile(); + + // Initialize BlockProperties + initBlockProperties(config); // Allow entries to TickTask (just in case). TickTask.setLocked(false); - - // - final ConfigFile config = ConfigManager.getConfigFile(); - BlockProperties.applyConfig(config, ConfPaths.COMPATIBILITY_BLOCKS); // Temp probably, // List the events listeners and register. manageListeners = config.getBoolean(ConfPaths.MISCELLANEOUS_MANAGELISTENERS); @@ -483,12 +478,9 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI { // Only for reloading, not INeedConfig. @Override public void onReload() { - // Reset MCAccess. - mcAccess = null; - // Reset BlockProperties. - BlockProperties.init(getMCAccess()); final ConfigFile config = ConfigManager.getConfigFile(); - BlockProperties.applyConfig(config, ConfPaths.COMPATIBILITY_BLOCKS); + // Initialize BlockProperties + initBlockProperties(config); // Reset Command protection. undoCommandChanges(); if (config.getBoolean(ConfPaths.MISCELLANEOUS_PROTECTPLUGINS)) setupCommandProtection(); @@ -604,6 +596,17 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI { LogUtil.logInfo("[NoCheatPlus] Version " + getDescription().getVersion() + " is enabled."); } + /** + * Reset MCAccess and (re-) initialize BlockProperties, including config. + */ + protected void initBlockProperties(ConfigFile config){ + // Reset MCAccess. + mcAccess = null; + // Set up BlockProperties. + BlockProperties.init(getMCAccess()); + BlockProperties.applyConfig(config, ConfPaths.COMPATIBILITY_BLOCKS); + } + /** * Actions to be done after enable of all plugins. This aims at reloading mainly. */