Fixes a bug in the preset prefix logic
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good

This commit is contained in:
Kristian Knarvik 2023-01-11 02:46:30 +01:00
parent bd00a59d08
commit f192a5a2b5
3 changed files with 10 additions and 4 deletions

View File

@ -85,7 +85,8 @@ public class GlobalSettings {
* @param newValue <p>The new value for the setting</p> * @param newValue <p>The new value for the setting</p>
*/ */
public void changeValue(NPCSetting npcSetting, Object newValue) { public void changeValue(NPCSetting npcSetting, Object newValue) {
if (npcSetting.getValueType() == SettingValueType.STRING_LIST) { if (npcSetting.getValueType() == SettingValueType.STRING_LIST ||
npcSetting.getValueType() == SettingValueType.REFORGE_ABLE_ITEMS) {
//Workaround to make sure it's treated as the correct type //Workaround to make sure it's treated as the correct type
defaultNPCSettings.put(npcSetting, newValue == null ? null : ConfigHelper.asStringList(newValue)); defaultNPCSettings.put(npcSetting, newValue == null ? null : ConfigHelper.asStringList(newValue));
} else { } else {

View File

@ -68,7 +68,8 @@ public class NPCSettings {
* @param newValue <p>The new value of the setting</p> * @param newValue <p>The new value of the setting</p>
*/ */
public void changeSetting(NPCSetting setting, Object newValue) { public void changeSetting(NPCSetting setting, Object newValue) {
if (setting.getValueType() == SettingValueType.STRING_LIST) { if (setting.getValueType() == SettingValueType.STRING_LIST ||
setting.getValueType() == SettingValueType.REFORGE_ABLE_ITEMS) {
//Workaround to make sure it's treated as the correct type //Workaround to make sure it's treated as the correct type
currentValues.put(setting, newValue == null ? null : ConfigHelper.asStringList(newValue)); currentValues.put(setting, newValue == null ? null : ConfigHelper.asStringList(newValue));
} else { } else {
@ -371,8 +372,11 @@ public class NPCSettings {
* @return <p>The value with placeholders replaced</p> * @return <p>The value with placeholders replaced</p>
*/ */
private static List<String> replaceReforgeAblePresets(List<String> stringList) { private static List<String> replaceReforgeAblePresets(List<String> stringList) {
List<String> newStrings = new ArrayList<>(stringList); List<String> newStrings = new ArrayList<>();
for (String item : stringList) { for (String item : stringList) {
if (item == null) {
continue;
}
String replaced = SmithPreset.replacePreset(item); String replaced = SmithPreset.replacePreset(item);
if (!replaced.equals(item)) { if (!replaced.equals(item)) {
newStrings.addAll(List.of(replaced.split(","))); newStrings.addAll(List.of(replaced.split(",")));

View File

@ -94,7 +94,8 @@ public enum SmithPreset {
negated = true; negated = true;
} }
if ((negated && !upperCasedPreset.startsWith("_PRESET:")) && !upperCasedPreset.startsWith("PRESET:")) { if ((negated && !upperCasedPreset.startsWith("_PRESET:")) ||
(!negated && !upperCasedPreset.startsWith("PRESET:"))) {
return possiblePreset; return possiblePreset;
} }