From 0114dd7558f59747ed9215e83c0068a5268075c4 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sun, 5 Jun 2016 18:42:34 +1000 Subject: [PATCH] Fix convert --- .../com/intellectualcrafters/plot/PS.java | 22 +++++++++---------- .../plot/config/Settings.java | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java index 9510e4d17..62248baf9 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java @@ -1840,13 +1840,13 @@ public class PS { /** * Setup the default configuration (settings.yml) */ - public void setupConfig() { + public void setupConfig() throws IOException { String lastVersionString = this.config.getString("version"); if (lastVersionString != null) { String[] split = lastVersionString.split("\\."); this.lastVersion = new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])}; } - if (checkVersion(new int[]{3,4,0}, version)) { + if (checkVersion(lastVersion, new int[]{3,4,0})) { Settings.convertLegacy(configFile); if (config.contains("worlds")) { ConfigurationSection worldSection = config.getConfigurationSection("worlds"); @@ -1878,6 +1878,15 @@ public class PS { if (!folder.exists() && !folder.mkdirs()) { PS.log(C.PREFIX + "&cFailed to create the /plugins/config folder. Please create it manually."); } + try { + this.worldsFile = new File(folder,"worlds.yml"); + if (!this.worldsFile.exists() && !this.worldsFile.createNewFile()) { + PS.log("Could not create the worlds file, please create \"worlds.yml\" manually."); + } + this.worlds = YamlConfiguration.loadConfiguration(this.worldsFile); + } catch (IOException ignored) { + PS.log("Failed to save settings.yml"); + } try { this.configFile = new File(folder,"settings.yml"); if (!this.configFile.exists() && !this.configFile.createNewFile()) { @@ -1904,15 +1913,6 @@ public class PS { err.printStackTrace(); PS.log("failed to save style.yml"); } - try { - this.worldsFile = new File(folder,"worlds.yml"); - if (!this.worldsFile.exists() && !this.worldsFile.createNewFile()) { - PS.log("Could not create the worlds file, please create \"worlds.yml\" manually."); - } - this.worlds = YamlConfiguration.loadConfiguration(this.worldsFile); - } catch (IOException ignored) { - PS.log("Failed to save settings.yml"); - } try { this.storageFile = new File(folder,"storage.yml"); if (!this.storageFile.exists() && !this.storageFile.createNewFile()) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/Core/src/main/java/com/intellectualcrafters/plot/config/Settings.java index de4e32035..aed7798ad 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -29,7 +29,7 @@ public class Settings extends Config { public static boolean TITLES = true; @Create // This value will be generated automatically - public static final ConfigBlock AUTO_CLEAR = null; // A ConfigBlock is a section that can have multiple instances e.g. multiple expiry tasks + public static ConfigBlock AUTO_CLEAR = null; // A ConfigBlock is a section that can have multiple instances e.g. multiple expiry tasks @Comment("This is an auto clearing task called `task1`") @BlockName("task1") // The name for the default block @@ -236,7 +236,7 @@ public class Settings extends Config { ENABLED_COMPONENTS.PLOT_EXPIRY = config.getBoolean("clear.auto.enabled", ENABLED_COMPONENTS.PLOT_EXPIRY); if (ENABLED_COMPONENTS.PLOT_EXPIRY) { ENABLED_COMPONENTS.BAN_DELETER = config.getBoolean("clear.on.ban"); - + AUTO_CLEAR = new ConfigBlock<>(); AUTO_CLEAR.put("task1", new AUTO_CLEAR()); AUTO_CLEAR task = AUTO_CLEAR.get("task1"); task.CALIBRATION = new AUTO_CLEAR.CALIBRATION();