Makes it possible to edit reforgeAbleItems globally #17
This commit is contained in:
@ -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()) {
|
||||
|
@ -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))));
|
||||
|
@ -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
|
||||
*/
|
||||
|
Reference in New Issue
Block a user