diff --git a/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java b/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java index 48d6a87..a3414f5 100644 --- a/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java +++ b/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java @@ -22,6 +22,8 @@ import net.knarcraft.knarlib.formatting.StringFormatter; import net.knarcraft.knarlib.formatting.TranslatableMessage; import net.knarcraft.knarlib.formatting.TranslatableTimeUnit; import net.knarcraft.knarlib.formatting.Translator; +import net.knarcraft.knarlib.property.ColorConversion; +import net.knarcraft.knarlib.util.FileHelper; import net.knarcraft.knarlib.util.UpdateChecker; import org.bukkit.command.CommandExecutor; import org.bukkit.command.PluginCommand; @@ -35,6 +37,9 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; import java.util.logging.Level; /** @@ -142,8 +147,12 @@ public class BlacksmithPlugin extends JavaPlugin { //Copy default config to disk FileConfiguration fileConfiguration = this.getConfig(); - fileConfiguration.options().copyDefaults(true); this.saveDefaultConfig(); + if (fileConfiguration.getString("defaults.dropItem") != null) { + migrateConfig(fileConfiguration); + this.saveConfig(); + } + fileConfiguration.options().copyDefaults(true); this.reloadConfig(); this.saveConfig(); @@ -253,4 +262,48 @@ public class BlacksmithPlugin extends JavaPlugin { } } + /** + * Changes all configuration values from the old name to the new name + * + * @param fileConfiguration
The config to read from and write to
+ */ + private void migrateConfig(FileConfiguration fileConfiguration) { + //Save the old config just in case something goes wrong + try { + fileConfiguration.save(getDataFolder() + "/config.yml.old"); + } catch (IOException e) { + e.printStackTrace(); + return; + } + + //Read all available config migrations + MapThis will throw an exception if used for a non-double setting
- * - * @param settingThe setting to get the value of
- * @returnThe value of the given setting as a double
- */ - public double asDouble(ScrapperSetting setting) { - return ConfigHelper.asDouble(getValue(setting)); - } - /** * Gets the value of a setting, using the default if not set * @@ -137,12 +125,12 @@ public class GlobalScrapperSettings implements Settings