From 37d146e8faa335be4748279a637e9583e2b58c5c Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 6 May 2012 14:51:25 -0700 Subject: [PATCH] Fixed various NPE errors when loading up mcMMO --- .../java/com/gmail/nossr50/config/Config.java | 2 +- .../nossr50/listeners/PlayerListener.java | 3 +-- src/main/java/com/gmail/nossr50/mcMMO.java | 24 ++++++++++++------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index dd941473e..e5bc6a3e8 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -440,7 +440,7 @@ public class Config extends ConfigLoader { public HUDType defaulthud; - private Config(mcMMO plugin) { + public Config(mcMMO plugin) { super(plugin, "config.yml"); config = plugin.getConfig(); xpGainMultiplier = getExperienceGainsGlobalMultiplier(); diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index eb6d729d5..c7d72aa74 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -316,8 +316,7 @@ public class PlayerListener implements Listener { event.setFormat(bracketColor + "(" + ChatColor.WHITE + "%1$s" + bracketColor + ") %2$s"); event.getRecipients().retainAll(intendedRecipients); - } - else if (PP.getAdminChatMode()) { + } else if (PP.getAdminChatMode()) { McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), event.getMessage()); plugin.getServer().getPluginManager().callEvent(chatEvent); diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 93f7e8b97..acb177f8f 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -51,24 +51,23 @@ public class mcMMO extends JavaPlugin { public static mcMMO p; /* Jar Stuff */ - public final File mcmmo = getFile(); + public File mcmmo; //File Paths - public final String mainDirectory = getDataFolder().getPath() + File.separator; - public final String flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator; - public final String usersFile = flatFileDirectory + "mcmmo.users"; - public final String leaderboardDirectory = flatFileDirectory + "Leaderboards" + File.separator; - public final String modDirectory = mainDirectory + "ModConfigs" + File.separator; + public String mainDirectory, flatFileDirectory, usersFile, leaderboardDirectory, modDirectory; - private static Config configInstance = Config.getInstance(); + private static Config configInstance = null; /** * Things to be run when the plugin is enabled. */ public void onEnable() { p = this; - + setupFilePaths(); + + configInstance = new Config(this); configInstance.load(); + LoadTreasures.getInstance().load(); if (configInstance.getToolModsEnabled()) { @@ -130,6 +129,15 @@ public class mcMMO extends JavaPlugin { } } } + + public void setupFilePaths() { + mcmmo = getFile(); + mainDirectory = getDataFolder().getPath() + File.separator; + flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator; + usersFile = flatFileDirectory + "mcmmo.users"; + leaderboardDirectory = flatFileDirectory + "Leaderboards" + File.separator; + modDirectory = mainDirectory + "ModConfigs" + File.separator; + } /** * Get profile of the player.