Removes disableMaterialLimitation
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
All checks were successful
EpicKnarvik97/Blacksmith/pipeline/head This commit looks good
Removes the disableMaterialLimitation option Replaces EnchantmentTarget.BREAKABLE.includes(item) with getMaxDurability(item) > 0 as it seems more generic
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
package net.knarcraft.blacksmith.util;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.EnchantmentTarget;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
|
||||
@ -20,13 +19,11 @@ public final class ItemHelper {
|
||||
/**
|
||||
* Gets whether the given item is repairable
|
||||
*
|
||||
* @param item <p>The item to check</p>
|
||||
* @param disableMaterialLimitation <p>Whether to disable the EnchantmentTarget.BREAKABLE limitation</p>
|
||||
* @param item <p>The item to check</p>
|
||||
* @return <p>True if the item is repairable</p>
|
||||
*/
|
||||
public static boolean isRepairable(ItemStack item, boolean disableMaterialLimitation) {
|
||||
return item.getItemMeta() instanceof Damageable && (disableMaterialLimitation ||
|
||||
EnchantmentTarget.BREAKABLE.includes(item));
|
||||
public static boolean isRepairable(ItemStack item) {
|
||||
return item.getItemMeta() instanceof Damageable && getMaxDurability(item) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,7 +76,7 @@ public final class ItemHelper {
|
||||
List<Material> reforgeAbleMaterials = new ArrayList<>();
|
||||
for (Material material : Material.values()) {
|
||||
ItemStack item = new ItemStack(material);
|
||||
if (item.getItemMeta() instanceof Damageable && EnchantmentTarget.BREAKABLE.includes(item)) {
|
||||
if (isRepairable(item)) {
|
||||
reforgeAbleMaterials.add(material);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user