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
|
* 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>
|
* @return <p>The value with placeholders replaced</p>
|
||||||
*/
|
*/
|
||||||
private static Object replaceReforgeAblePresets(Object value) {
|
private static List<String> replaceReforgeAblePresets(List<String> stringList) {
|
||||||
if (value instanceof String string) {
|
List<String> newStrings = new ArrayList<>(stringList);
|
||||||
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);
|
|
||||||
for (String item : stringList) {
|
for (String item : stringList) {
|
||||||
replaced.add(SmithPreset.replacePreset(item));
|
String replaced = SmithPreset.replacePreset(item);
|
||||||
}
|
if (!replaced.equals(item)) {
|
||||||
return replaced.toArray();
|
newStrings.addAll(List.of(replaced.split(",")));
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Unexpected object type encountered!");
|
newStrings.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return newStrings;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the list of blocked enchantments
|
* Updates the list of blocked enchantments
|
||||||
@ -444,8 +438,10 @@ public class NPCSettings {
|
|||||||
return null;
|
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
|
//Parse every material, and add to reforgeAble items
|
||||||
for (String item : itemList) {
|
for (String item : itemList) {
|
||||||
//Ignore ,,
|
//Ignore ,,
|
||||||
@ -453,9 +449,6 @@ public class NPCSettings {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Convert any presets with a list of materials
|
|
||||||
item = (String) replaceReforgeAblePresets(item);
|
|
||||||
|
|
||||||
boolean blacklist = false;
|
boolean blacklist = false;
|
||||||
if (item.startsWith("-")) {
|
if (item.startsWith("-")) {
|
||||||
blacklist = true;
|
blacklist = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user