diff --git a/README.md b/README.md index a1e7670..dd4fa1c 100644 --- a/README.md +++ b/README.md @@ -71,8 +71,8 @@ the default one instead. ### Presets and filters: -Presets are a nice way to make specialized blacksmiths by specifying categories of materials, instead of manually -listing every material manually. They can only be used for the `reforgeAbleItems` option. +**Presets are a nice way to make specialized blacksmiths by specifying categories of materials, instead of manually +listing every material manually. They can only be used for the `reforgeAbleItems` option.** Note: All of these can be used when specifying reforge-able items, such as "preset:weapon-smith:bow,preset:armor_smith:gold,PRESET:TOOL_SMITH,shield" diff --git a/src/main/java/net/knarcraft/blacksmith/config/NPCSettings.java b/src/main/java/net/knarcraft/blacksmith/config/NPCSettings.java index 6cb7c58..61d13b4 100644 --- a/src/main/java/net/knarcraft/blacksmith/config/NPCSettings.java +++ b/src/main/java/net/knarcraft/blacksmith/config/NPCSettings.java @@ -410,14 +410,17 @@ public class NPCSettings { //Parse every material, and add to reforgeAble items for (String item : newReforgeAbleItems.split(",")) { + //Ignore ,, if (InputParsingHelper.isEmpty(item)) { continue; } + boolean blacklist = false; if (item.startsWith("-")) { blacklist = true; item = item.substring(1); } + Material material = InputParsingHelper.matchMaterial(item); if (material != null && BlacksmithTrait.isRepairable(new ItemStack(material, 1))) { if (!blacklist) { @@ -432,9 +435,7 @@ public class NPCSettings { } //Remove any blacklisted materials at the end to make sure order of arguments won't matter - for (Material material : blacklisted) { - reforgeAbleItems.remove(material); - } + this.reforgeAbleItems.removeAll(blacklisted); } } \ No newline at end of file diff --git a/src/main/java/net/knarcraft/blacksmith/config/SmithPreset.java b/src/main/java/net/knarcraft/blacksmith/config/SmithPreset.java index 75e2075..fb6b09e 100644 --- a/src/main/java/net/knarcraft/blacksmith/config/SmithPreset.java +++ b/src/main/java/net/knarcraft/blacksmith/config/SmithPreset.java @@ -88,16 +88,21 @@ public enum SmithPreset { */ public static String replacePreset(String possiblePreset) { boolean negated = false; - if (possiblePreset.startsWith("-")) { - negated = true; - possiblePreset = possiblePreset.substring(1); - } String upperCasedPreset = possiblePreset.replace('-', '_').toUpperCase(); - if (!upperCasedPreset.startsWith("PRESET:")) { + if (possiblePreset.startsWith("-")) { + negated = true; + } + + if ((negated && !upperCasedPreset.startsWith("_PRESET:")) && !upperCasedPreset.startsWith("PRESET:")) { return possiblePreset; } + //Strip the "-" here to prevent stripping for material names + if (negated) { + upperCasedPreset = upperCasedPreset.substring(1); + } + //Parse the input SmithPresetFilter filter = null; SmithPreset preset;