A lot of tests, and some improvements
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good

Adds a lot more tests for some utility classes
Adds a new option to disable the hard-coded limitation "EnchantmentTarget.BREAKABLE" which can be useful for servers with custom items or similar.
Makes enchantment name matching case-insensitive.
Prevents an exception is enchantment name contains invalid characters.
Makes invalid objects supplied to asStringList return null instead of throwing an exception.
Uses isBlank instead of trim.isEmpty in the isEmpty method
Re-uses the random generator if calculating salvage several times
This commit is contained in:
2023-01-16 17:42:54 +01:00
parent 7d468115e0
commit e5cb3b4a30
13 changed files with 379 additions and 28 deletions

View File

@ -49,7 +49,15 @@ public enum GlobalSetting {
* The cost for repairing a damaged anvil
*/
ANVIL_DAMAGED_COST("global.damagedAnvilReforgingCost", SettingValueType.POSITIVE_DOUBLE, 20.0,
"damagedAnvilReforgingCost");
"damagedAnvilReforgingCost"),
/**
* Whether to disable the normal limitation for which items are reforgeAble
*
* <p>If true, all items instanceof Damageable can be reforged</p>
*/
DISABLE_MATERIAL_LIMITATION("global.disableMaterialLimitation", SettingValueType.BOOLEAN, false,
"disableMaterialLimitation");
private final String path;
private final String parent;

View File

@ -295,6 +295,15 @@ public class GlobalSettings {
}
}
/**
* Whether to disable the "EnchantmentTarget.BREAKABLE" limitation
*
* @return <p>True if the material limitation is disabled</p>
*/
public boolean disableMaterialLimitation() {
return asBoolean(GlobalSetting.DISABLE_MATERIAL_LIMITATION);
}
/**
* Gets the given value as a boolean
*

View File

@ -460,7 +460,8 @@ public class NPCSettings {
}
Material material = InputParsingHelper.matchMaterial(item);
if (material != null && ItemHelper.isRepairable(new ItemStack(material, 1))) {
boolean limitationDisabled = BlacksmithPlugin.getInstance().getSettings().disableMaterialLimitation();
if (material != null && ItemHelper.isRepairable(new ItemStack(material, 1), limitationDisabled)) {
if (!blacklist) {
reforgeAbleItems.add(material);
} else {