diff --git a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java index dbcd711a..651808c2 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MultiverseCore.java @@ -259,6 +259,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core { Configuration coreDefaults = YamlConfiguration.loadConfiguration(this.getClass().getResourceAsStream("/defaults/config.yml")); this.multiverseConfig.setDefaults(coreDefaults); this.multiverseConfig.options().copyDefaults(true); + this.saveMVConfig(); + this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml")); this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml")); // Setup the Debug option, we'll default to false because this option will not be in the default config. @@ -271,8 +273,6 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core { this.messaging = new MVMessaging(this); this.messaging.setCooldown(this.multiverseConfig.getInt("messagecooldown", 5000)); this.saveMVConfigs(); - // Reload the configs because they're null in memory if they were default. - this.multiverseConfig = YamlConfiguration.loadConfiguration(new File(getDataFolder(), "config.yml")); } public MVMessaging getMessaging() { @@ -609,16 +609,21 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core { return false; } - public boolean saveMVConfigs() { - boolean retVal = true; + public boolean saveMVConfig() { try { this.multiverseConfig.save(new File(getDataFolder(), "config.yml")); + return true; } catch (IOException e) { - retVal = false; this.log(Level.SEVERE, "Could not save Multiverse config.yml config. Please check your file permissions."); + return false; } + } - this.worldManager.saveWorldsConfig(); - return retVal; + public boolean saveWorldConfig() { + return this.worldManager.saveWorldsConfig(); + } + + public boolean saveMVConfigs() { + return this.saveMVConfig() && this.saveWorldConfig(); } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/utils/WorldManager.java b/src/main/java/com/onarandombox/MultiverseCore/utils/WorldManager.java index 89a92d40..1c12aa88 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/utils/WorldManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/utils/WorldManager.java @@ -411,11 +411,13 @@ public class WorldManager implements MVWorldManager { return this.configWorlds; } - public void saveWorldsConfig() { + public boolean saveWorldsConfig() { try { this.configWorlds.save(new File(this.plugin.getDataFolder(), "worlds.yml")); + return true; } catch (IOException e) { this.plugin.log(Level.SEVERE, "Could not save worlds.yml. Please check your settings."); + return false; } } }