From 40b609ccd8a4a49b278c5780fbb60be3e11e814a Mon Sep 17 00:00:00 2001 From: ezeiger92 Date: Thu, 15 Feb 2018 13:38:10 -0800 Subject: [PATCH] Respect unbreakable tag on items when attempting durability changes Fixes mcMMO-Dev/mcMMO#3327 Fixes mcMMO-Dev/mcMMO#3391 --- src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index e384d07bc..860a60117 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -188,6 +188,10 @@ public class SkillUtils { * @param maxDamageModifier the amount to adjust the max damage by */ public static void handleDurabilityChange(ItemStack itemStack, int durabilityModifier, double maxDamageModifier) { + if(itemStack.hasItemMeta() && itemStack.getItemMeta().isUnbreakable()) { + return; + } + Material type = itemStack.getType(); short maxDurability = mcMMO.getRepairableManager().isRepairable(type) ? mcMMO.getRepairableManager().getRepairable(type).getMaximumDurability() : type.getMaxDurability(); durabilityModifier = (int) Math.min(durabilityModifier / (itemStack.getEnchantmentLevel(Enchantment.DURABILITY) + 1), maxDurability * maxDamageModifier);