1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 03:35:51 +00:00

Fixed Durability Enchantment on damageable Items

This commit is contained in:
TheBusyBiscuit 2019-09-02 11:27:32 +02:00
parent dd14816504
commit 6473988df4

View File

@ -13,7 +13,11 @@ public interface DamageableItem {
boolean isDamageable(); boolean isDamageable();
default void damageItem(Player p, ItemStack item) { default void damageItem(Player p, ItemStack item) {
if (item != null && item.getType() != null && item.getType() != Material.AIR && item.getAmount() > 0 && isDamageable() && item.getEnchantments().containsKey(Enchantment.DURABILITY) && Math.random() * 100 <= (60 + Math.floorDiv(40, (item.getEnchantmentLevel(Enchantment.DURABILITY) + 1)))) { if (item != null && item.getType() != null && item.getType() != Material.AIR && item.getAmount() > 0 && isDamageable()) {
if (item.getEnchantments().containsKey(Enchantment.DURABILITY) && Math.random() * 100 <= (60 + Math.floorDiv(40, (item.getEnchantmentLevel(Enchantment.DURABILITY) + 1)))) {
return;
}
ItemMeta meta = item.getItemMeta(); ItemMeta meta = item.getItemMeta();
Damageable damageable = (Damageable) meta; Damageable damageable = (Damageable) meta;