Fixes handling of preset replacement
This commit is contained in:
parent
488d4c7589
commit
8423eabc57
@ -367,27 +367,21 @@ public class NPCSettings {
|
||||
/**
|
||||
* Replaces placeholders in the given reforge-able value
|
||||
*
|
||||
* @param value <p>The value specified by a user</p>
|
||||
* @param stringList <p>The value specified by a user</p>
|
||||
* @return <p>The value with placeholders replaced</p>
|
||||
*/
|
||||
private static Object replaceReforgeAblePresets(Object value) {
|
||||
if (value instanceof String string) {
|
||||
String[] list = string.split(",");
|
||||
List<String> replaced = new ArrayList<>(list.length);
|
||||
for (String item : list) {
|
||||
replaced.add(SmithPreset.replacePreset(item));
|
||||
}
|
||||
return String.join(",", replaced);
|
||||
} else if (value instanceof String[] stringList) {
|
||||
List<String> replaced = new ArrayList<>(stringList.length);
|
||||
private static List<String> replaceReforgeAblePresets(List<String> stringList) {
|
||||
List<String> newStrings = new ArrayList<>(stringList);
|
||||
for (String item : stringList) {
|
||||
replaced.add(SmithPreset.replacePreset(item));
|
||||
}
|
||||
return replaced.toArray();
|
||||
String replaced = SmithPreset.replacePreset(item);
|
||||
if (!replaced.equals(item)) {
|
||||
newStrings.addAll(List.of(replaced.split(",")));
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unexpected object type encountered!");
|
||||
newStrings.add(item);
|
||||
}
|
||||
}
|
||||
return newStrings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the list of blocked enchantments
|
||||
@ -444,8 +438,10 @@ public class NPCSettings {
|
||||
return null;
|
||||
}
|
||||
|
||||
Set<Material> blacklisted = new HashSet<>();
|
||||
//Convert any presets with a list of materials
|
||||
itemList = replaceReforgeAblePresets(itemList);
|
||||
|
||||
Set<Material> 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;
|
||||
|
Loading…
Reference in New Issue
Block a user