Adds an option for toggling whether reforging removing enchantments
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good

This commit is contained in:
2023-01-30 12:34:34 +01:00
parent faff982585
commit cb70874093
5 changed files with 75 additions and 33 deletions

View File

@ -17,6 +17,12 @@ public enum NPCSetting {
*/
FAIL_CHANCE("failReforgeChance", SettingValueType.PERCENTAGE, 10, "failReforgeChance"),
/**
* The setting for whether failing a reforging should downgrade/remove enchantments as well
*/
FAIL_REMOVE_ENCHANTMENTS("failReforgeRemovesEnchantments", SettingValueType.BOOLEAN, false,
"failReforgeRemovesEnchantments"),
/**
* The setting for the chance of an additional enchantment being added
*/

View File

@ -258,6 +258,15 @@ public class NPCSettings {
return asInt(NPCSetting.FAIL_CHANCE);
}
/**
* Gets whether a failed reforging should remove/downgrade enchantments
*
* @return <p>Whether enchantments should be removed</p>
*/
public boolean getFailRemovesEnchantments() {
return asBoolean(NPCSetting.FAIL_REMOVE_ENCHANTMENTS);
}
/**
* Gets the chance for adding an extra enchantment to an item
*
@ -282,7 +291,7 @@ public class NPCSettings {
* @return <p>Whether to drop reforged items on the ground</p>
*/
public boolean getDropItem() {
return ConfigHelper.asBoolean(getValue(NPCSetting.DROP_ITEM));
return asBoolean(NPCSetting.DROP_ITEM);
}
/**
@ -318,7 +327,7 @@ public class NPCSettings {
* @return <p>True if this blacksmith is able to repair anvils</p>
*/
public boolean getRepairAnvils() {
return ConfigHelper.asBoolean(getValue(NPCSetting.REPAIR_ANVILS));
return asBoolean(NPCSetting.REPAIR_ANVILS);
}
/**
@ -343,6 +352,16 @@ public class NPCSettings {
return getValue(setting).toString();
}
/**
* Gets the boolean value of the given setting
*
* @param setting <p>The setting to get the value of</p>
* @return <p>The value of the given setting as a boolean</p>
*/
private boolean asBoolean(NPCSetting setting) {
return ConfigHelper.asBoolean(getValue(setting));
}
/**
* Gets the value of a setting, using the default if not set
*