From 3d333c640633215dac3be80a688869678e9c9183 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Mon, 3 Oct 2022 15:41:00 +0200 Subject: [PATCH] Fix for #6 --- .../java/net/knarcraft/blacksmith/BlacksmithPlugin.java | 2 ++ .../java/net/knarcraft/blacksmith/config/NPCSettings.java | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java b/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java index 1dc7cf3..80ec815 100644 --- a/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java +++ b/src/main/java/net/knarcraft/blacksmith/BlacksmithPlugin.java @@ -62,7 +62,9 @@ public class BlacksmithPlugin extends JavaPlugin { //Copy default config to disk FileConfiguration fileConfiguration = this.getConfig(); this.saveDefaultConfig(); + this.reloadConfig(); fileConfiguration.options().copyDefaults(true); + this.saveConfig(); //Load settings config = new GlobalSettings(this); diff --git a/src/main/java/net/knarcraft/blacksmith/config/NPCSettings.java b/src/main/java/net/knarcraft/blacksmith/config/NPCSettings.java index 5c2693e..ff9d3a5 100644 --- a/src/main/java/net/knarcraft/blacksmith/config/NPCSettings.java +++ b/src/main/java/net/knarcraft/blacksmith/config/NPCSettings.java @@ -63,7 +63,6 @@ public class NPCSettings { */ public void changeSetting(NPCSetting setting, Object newValue) { if (setting == NPCSetting.REFORGE_ABLE_ITEMS) { - newValue = replaceReforgeAblePlaceholders(newValue); currentValues.put(setting, newValue); updateReforgeAbleItems(); } else { @@ -334,7 +333,7 @@ public class NPCSettings { * @param value

The value specified by a user

* @return

The value with placeholders replaced

*/ - private Object replaceReforgeAblePlaceholders(Object value) { + private Object replaceReforgeAblePresets(Object value) { if (value instanceof String string) { String[] list = string.split(","); List replaced = new ArrayList<>(list.length); @@ -363,6 +362,9 @@ public class NPCSettings { return; } + //Convert any presets with a list of materials + newReforgeAbleItems = (String) replaceReforgeAblePresets(newReforgeAbleItems); + for (String item : newReforgeAbleItems.split(",")) { if (item == null || item.equalsIgnoreCase("null")) { continue;