diff --git a/src/main/java/net/knarcraft/blacksmith/command/BlackSmithConfigCommand.java b/src/main/java/net/knarcraft/blacksmith/command/BlackSmithConfigCommand.java index 7704a03..5449e39 100644 --- a/src/main/java/net/knarcraft/blacksmith/command/BlackSmithConfigCommand.java +++ b/src/main/java/net/knarcraft/blacksmith/command/BlackSmithConfigCommand.java @@ -40,13 +40,6 @@ public class BlackSmithConfigCommand implements CommandExecutor { } GlobalSettings settings = BlacksmithPlugin.getInstance().getSettings(); - //Changing reforge-able items' default isn't recommended - if (commandName.equalsIgnoreCase(NPCSetting.REFORGE_ABLE_ITEMS.getCommandName())) { - BlacksmithPlugin.getStringFormatter().displayErrorMessage(sender, - BlacksmithTranslatableMessage.DEFAULT_REFORGE_ABLE_ITEMS_UNCHANGEABLE); - return false; - } - //Find which global setting the user has specified, if any GlobalSetting detectedGlobalSetting = null; for (GlobalSetting globalSetting : GlobalSetting.values()) { diff --git a/src/main/java/net/knarcraft/blacksmith/config/GlobalSettings.java b/src/main/java/net/knarcraft/blacksmith/config/GlobalSettings.java index 5e3411a..00eef5d 100644 --- a/src/main/java/net/knarcraft/blacksmith/config/GlobalSettings.java +++ b/src/main/java/net/knarcraft/blacksmith/config/GlobalSettings.java @@ -92,6 +92,11 @@ public class GlobalSettings { defaultNPCSettings.put(npcSetting, newValue); } save(); + if (npcSetting == NPCSetting.REFORGE_ABLE_ITEMS) { + loadReforgeAbleItems(); + } else if (npcSetting == NPCSetting.ENCHANTMENT_BLOCKLIST) { + loadEnchantmentBlocklist(); + } } /** @@ -482,9 +487,23 @@ public class GlobalSettings { defaultNPCSettings.put(setting, root.getRaw(setting.getPath())); } } + loadReforgeAbleItems(); + loadEnchantmentBlocklist(); + } + + /** + * Loads reforgeAble items from the current value + */ + private void loadReforgeAbleItems() { defaultReforgeAbleMaterials.clear(); defaultReforgeAbleMaterials.addAll(NPCSettings.getReforgeAbleItems(ConfigHelper.asStringList( defaultNPCSettings.get(NPCSetting.REFORGE_ABLE_ITEMS)))); + } + + /** + * Loads the enchantment blocklist from the current value + */ + private void loadEnchantmentBlocklist() { defaultEnchantmentBlocklist.clear(); defaultEnchantmentBlocklist.addAll(NPCSettings.getEnchantmentBlocklist(ConfigHelper.asStringList( defaultNPCSettings.get(NPCSetting.ENCHANTMENT_BLOCKLIST)))); diff --git a/src/main/java/net/knarcraft/blacksmith/formatting/BlacksmithTranslatableMessage.java b/src/main/java/net/knarcraft/blacksmith/formatting/BlacksmithTranslatableMessage.java index 32efa2a..87b7ae6 100644 --- a/src/main/java/net/knarcraft/blacksmith/formatting/BlacksmithTranslatableMessage.java +++ b/src/main/java/net/knarcraft/blacksmith/formatting/BlacksmithTranslatableMessage.java @@ -52,11 +52,6 @@ public enum BlacksmithTranslatableMessage implements TranslatableMessage { */ NO_NPC_SELECTED, - /** - * The message displayed if trying to change the default value of reforge-able item using commands - */ - DEFAULT_REFORGE_ABLE_ITEMS_UNCHANGEABLE, - /** * The message displayed if a string list is required, but something else is given */ diff --git a/src/main/resources/strings.yml b/src/main/resources/strings.yml index c3e4959..31436c3 100644 --- a/src/main/resources/strings.yml +++ b/src/main/resources/strings.yml @@ -7,7 +7,6 @@ en: ITEM_TYPE_MATERIAL: "material" RAW_VALUE: "Raw value: {rawValue}" NO_NPC_SELECTED: "You must select an NPC before running this command" - DEFAULT_REFORGE_ABLE_ITEMS_UNCHANGEABLE: "Changing reforge-able items globally will make every new blacksmith unable to reforge anything not in the list, unless it's changed for the individual NPC. If you really want to change this, change it manually." INPUT_STRING_LIST_REQUIRED: "A string list is required!" INPUT_PERCENTAGE_REQUIRED: "You specified a value which isn't between 0 and 100!" INPUT_STRING_REQUIRED: "A non-empty string is required!"