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

@ -20,11 +20,13 @@ public final class ItemHelper {
/**
* Gets whether the given item is repairable
*
* @param item <p>The item to check</p>
* @param item <p>The item to check</p>
* @param disableMaterialLimitation <p>Whether to disable the EnchantmentTarget.BREAKABLE limitation</p>
* @return <p>True if the item is repairable</p>
*/
public static boolean isRepairable(ItemStack item) {
return item.getItemMeta() instanceof Damageable && EnchantmentTarget.BREAKABLE.includes(item);
public static boolean isRepairable(ItemStack item, boolean disableMaterialLimitation) {
return item.getItemMeta() instanceof Damageable && (disableMaterialLimitation ||
EnchantmentTarget.BREAKABLE.includes(item));
}
/**