Fixes reforge-able items and displaying color formatting codes

This commit is contained in:
2022-10-02 21:03:17 +02:00
parent a6e9163dbd
commit f058f4eec8
6 changed files with 27 additions and 28 deletions

View File

@ -24,8 +24,10 @@ public enum NPCSetting {
-----------*/
BUSY_WITH_PLAYER_MESSAGE("defaults.messages.busy-with-player", SettingValueType.STRING,
"&cI'm busy at the moment. Come back later!", "busyPlayerMessage"),
//TODO: Add placeholder for remaining time?
BUSY_WITH_REFORGE_MESSAGE("defaults.messages.busy-with-reforge", SettingValueType.STRING,
"&cI'm working on it. Be patient!", "busyReforgeMessage"),
//TODO: Add placeholder for remaining time?
COOL_DOWN_UNEXPIRED_MESSAGE("defaults.messages.cool-down-not-expired", SettingValueType.STRING,
"&cYou've already had your chance! Give me a break!", "coolDownUnexpiredMessage"),
COST_MESSAGE(

View File

@ -64,8 +64,11 @@ public class NPCSettings {
public void changeSetting(NPCSetting setting, Object newValue) {
if (setting == NPCSetting.REFORGE_ABLE_ITEMS) {
newValue = replaceReforgeAblePlaceholders(newValue);
currentValues.put(setting, newValue);
updateReforgeAbleItems();
} else {
currentValues.put(setting, newValue);
}
currentValues.put(setting, newValue);
}
/**
@ -346,20 +349,20 @@ public class NPCSettings {
*/
private void updateReforgeAbleItems() {
this.reforgeAbleItems.clear();
List<?> reforgeAbleItems = (List<?>) currentValues.get(NPCSetting.REFORGE_ABLE_ITEMS);
if (reforgeAbleItems == null) {
String newReforgeAbleItems = (String) currentValues.get(NPCSetting.REFORGE_ABLE_ITEMS);
if (newReforgeAbleItems == null) {
return;
}
for (Object item : reforgeAbleItems) {
if (item == null) {
for (String item : newReforgeAbleItems.split(",")) {
if (item == null || item.equalsIgnoreCase("null")) {
continue;
}
Material material = Material.matchMaterial(String.valueOf(item));
Material material = Material.matchMaterial(item.replace('-', '_'));
if (material != null && BlacksmithTrait.isRepairable(new ItemStack(material, 1))) {
this.reforgeAbleItems.add(material);
} else {
BlacksmithPlugin.getInstance().getLogger().log(Level.WARNING, "Unable to verify " + material +
BlacksmithPlugin.getInstance().getLogger().log(Level.WARNING, "Unable to verify " + item +
" as a valid reforge-able item");
}
}

View File

@ -43,7 +43,8 @@ public enum SmithPreset {
*/
public static String replacePlaceholder(String possiblePlaceholder) {
for (SmithPreset smithPreset : SmithPreset.values()) {
if (possiblePlaceholder.equalsIgnoreCase("preset:" + smithPreset.name())) {
if (possiblePlaceholder.replace('-', '_').equalsIgnoreCase("preset:" +
smithPreset.name())) {
return String.join(",", smithPreset.getMaterialNames());
}
}