Fixed double Config instantiation causing NPE on PlayerProfile.save()

This commit is contained in:
bm01 2012-05-09 15:58:11 +02:00
parent 68b9857409
commit 06791beabd
3 changed files with 12 additions and 11 deletions

View File

@ -15,6 +15,7 @@ public class Config extends ConfigLoader {
public static Config getInstance() { public static Config getInstance() {
if (instance == null) { if (instance == null) {
instance = new Config(mcMMO.p); instance = new Config(mcMMO.p);
instance.load();
} }
return instance; return instance;
@ -440,14 +441,14 @@ public class Config extends ConfigLoader {
public HUDType defaulthud; public HUDType defaulthud;
public Config(mcMMO plugin) { private Config(mcMMO plugin) {
super(plugin, "config.yml"); super(plugin, "config.yml");
config = plugin.getConfig(); config = plugin.getConfig();
xpGainMultiplier = getExperienceGainsGlobalMultiplier(); xpGainMultiplier = getExperienceGainsGlobalMultiplier();
} }
@Override @Override
public void load() { protected void load() {
if (!configFile.exists()) { if (!configFile.exists()) {
dataFolder.mkdir(); dataFolder.mkdir();
plugin.saveDefaultConfig(); plugin.saveDefaultConfig();

View File

@ -22,6 +22,7 @@ public class LoadTreasures extends ConfigLoader{
public static LoadTreasures getInstance() { public static LoadTreasures getInstance() {
if (instance == null) { if (instance == null) {
instance = new LoadTreasures(mcMMO.p); instance = new LoadTreasures(mcMMO.p);
instance.load();
} }
return instance; return instance;
@ -46,7 +47,7 @@ public class LoadTreasures extends ConfigLoader{
} }
@Override @Override
public void load() { protected void load() {
if (!configFile.exists()) { if (!configFile.exists()) {
dataFolder.mkdir(); dataFolder.mkdir();
plugin.saveTreasuresConfig(); plugin.saveTreasuresConfig();

View File

@ -62,8 +62,6 @@ public class mcMMO extends JavaPlugin {
//File Paths //File Paths
public String mainDirectory, flatFileDirectory, usersFile, leaderboardDirectory, modDirectory; public String mainDirectory, flatFileDirectory, usersFile, leaderboardDirectory, modDirectory;
private static Config configInstance = null;
/** /**
* Things to be run when the plugin is enabled. * Things to be run when the plugin is enabled.
*/ */
@ -71,10 +69,9 @@ public class mcMMO extends JavaPlugin {
p = this; p = this;
setupFilePaths(); setupFilePaths();
configInstance = new Config(this); //Force the loading of config files
configInstance.load(); Config configInstance = Config.getInstance();
LoadTreasures.getInstance();
LoadTreasures.getInstance().load();
if (configInstance.getToolModsEnabled()) { if (configInstance.getToolModsEnabled()) {
LoadCustomTools.getInstance().load(); LoadCustomTools.getInstance().load();
@ -244,6 +241,8 @@ public class mcMMO extends JavaPlugin {
getCommand("unarmed").setExecutor(new UnarmedCommand()); getCommand("unarmed").setExecutor(new UnarmedCommand());
getCommand("woodcutting").setExecutor(new WoodcuttingCommand()); getCommand("woodcutting").setExecutor(new WoodcuttingCommand());
Config configInstance = Config.getInstance();
//mc* commands //mc* commands
if (configInstance.getCommandMCRemoveEnabled()) { if (configInstance.getCommandMCRemoveEnabled()) {
getCommand("mcremove").setExecutor(new McremoveCommand(this)); getCommand("mcremove").setExecutor(new McremoveCommand(this));