diff --git a/src/main/java/net/knarcraft/blacksmith/config/NPCSettings.java b/src/main/java/net/knarcraft/blacksmith/config/NPCSettings.java index a20366e..2361f21 100644 --- a/src/main/java/net/knarcraft/blacksmith/config/NPCSettings.java +++ b/src/main/java/net/knarcraft/blacksmith/config/NPCSettings.java @@ -367,26 +367,20 @@ public class NPCSettings { /** * Replaces placeholders in the given reforge-able value * - * @param value

The value specified by a user

+ * @param stringList

The value specified by a user

* @return

The value with placeholders replaced

*/ - private static Object replaceReforgeAblePresets(Object value) { - if (value instanceof String string) { - String[] list = string.split(","); - List replaced = new ArrayList<>(list.length); - for (String item : list) { - replaced.add(SmithPreset.replacePreset(item)); + private static List replaceReforgeAblePresets(List stringList) { + List newStrings = new ArrayList<>(stringList); + for (String item : stringList) { + String replaced = SmithPreset.replacePreset(item); + if (!replaced.equals(item)) { + newStrings.addAll(List.of(replaced.split(","))); + } else { + newStrings.add(item); } - return String.join(",", replaced); - } else if (value instanceof String[] stringList) { - List replaced = new ArrayList<>(stringList.length); - for (String item : stringList) { - replaced.add(SmithPreset.replacePreset(item)); - } - return replaced.toArray(); - } else { - throw new IllegalArgumentException("Unexpected object type encountered!"); } + return newStrings; } /** @@ -444,8 +438,10 @@ public class NPCSettings { return null; } - Set blacklisted = new HashSet<>(); + //Convert any presets with a list of materials + itemList = replaceReforgeAblePresets(itemList); + Set blacklisted = new HashSet<>(); //Parse every material, and add to reforgeAble items for (String item : itemList) { //Ignore ,, @@ -453,9 +449,6 @@ public class NPCSettings { continue; } - //Convert any presets with a list of materials - item = (String) replaceReforgeAblePresets(item); - boolean blacklist = false; if (item.startsWith("-")) { blacklist = true;