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

View File

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

View File

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