From 81140824e4a7205a8066f8773cf7bf16ee147217 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 7 Oct 2013 13:09:46 -0400 Subject: [PATCH] Backup and replace updated treasures.yml file. --- .../com/gmail/nossr50/config/ConfigLoader.java | 17 ++++++++++++++++- .../nossr50/config/treasure/TreasureConfig.java | 4 +--- .../skills/repair/config/RepairConfig.java | 16 ---------------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java index cf2b14006..40f7534b9 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigLoader.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigLoader.java @@ -11,7 +11,7 @@ import com.gmail.nossr50.mcMMO; public abstract class ConfigLoader { protected static final mcMMO plugin = mcMMO.p; protected String fileName; - protected File configFile; + private File configFile; protected FileConfiguration config; public ConfigLoader(String relativePath, String fileName) { @@ -66,4 +66,19 @@ public abstract class ConfigLoader { public File getFile() { return configFile; } + + public void backup() { + plugin.getLogger().warning("You are using an old version of the " + fileName + " file."); + plugin.getLogger().warning("Your old file has been renamed to " + fileName + ".old and has been replaced by an updated version."); + + configFile.renameTo(new File(configFile.getPath() + ".old")); + + if (plugin.getResource(fileName) != null) { + plugin.saveResource(fileName, true); + } + + plugin.getLogger().warning("Reloading " + fileName + " with new values..."); + loadFile(); + loadKeys(); + } } diff --git a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java index 39c5bce95..d2355deb1 100644 --- a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java @@ -75,9 +75,7 @@ public class TreasureConfig extends ConfigLoader { @Override protected void loadKeys() { if (config.getConfigurationSection("Treasures") != null) { - plugin.getLogger().warning("You are using an old version of the treasures.yml file."); - plugin.getLogger().warning("You should delete your current file and allow a new one to generate."); - plugin.getLogger().warning("Shake, Hylian Luck, Fishing, and Excavation will not work properly until you do."); + backup(); return; } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/config/RepairConfig.java b/src/main/java/com/gmail/nossr50/skills/repair/config/RepairConfig.java index d8da917e6..6b4560489 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/config/RepairConfig.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/config/RepairConfig.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.skills.repair.config; -import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -161,19 +160,4 @@ public class RepairConfig extends ConfigLoader { return issues.isEmpty(); } - - private void backup() { - plugin.getLogger().warning("You are using an old version of the " + fileName + " file."); - plugin.getLogger().warning("Your old file has been renamed to " + fileName + ".old and has been replaced by an updated version."); - - configFile.renameTo(new File(configFile.getPath() + ".old")); - - if (plugin.getResource(fileName) != null) { - plugin.saveResource(fileName, true); - } - - plugin.getLogger().warning("Reloading " + fileName + " with new values..."); - loadFile(); - loadKeys(); - } }