Browse Source

Super Abilities don't do extra durability damage to tools with the
unbreaking enchantment

nossr50 6 years ago
parent
commit
98f6eac50c

+ 2 - 1
Changelog.txt

@@ -1,5 +1,6 @@
 Version 2.1.78
 Version 2.1.78
-
+    Shovels no longer take more than 1 diamond to repair
+    Tools with the unbreaking enchantment no longer take extra damage from ability usage, they are still subject to the normal durability damage from breaking blocks though.
 
 
 Version 2.1.77
 Version 2.1.77
     Added minimum quantity back to Repair config
     Added minimum quantity back to Repair config

+ 6 - 0
src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java

@@ -10,6 +10,7 @@ import com.gmail.nossr50.util.skills.SkillUtils;
 import org.bukkit.Material;
 import org.bukkit.Material;
 import org.bukkit.block.BlockFace;
 import org.bukkit.block.BlockFace;
 import org.bukkit.block.BlockState;
 import org.bukkit.block.BlockState;
+import org.bukkit.enchantments.Enchantment;
 import org.bukkit.inventory.ItemStack;
 import org.bukkit.inventory.ItemStack;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
@@ -147,6 +148,11 @@ public final class Woodcutting {
      * @return True if the tool can sustain the durability loss
      * @return True if the tool can sustain the durability loss
      */
      */
     protected static boolean handleDurabilityLoss(Set<BlockState> treeFellerBlocks, ItemStack inHand) {
     protected static boolean handleDurabilityLoss(Set<BlockState> treeFellerBlocks, ItemStack inHand) {
+
+        if(inHand.getItemMeta().getEnchants().get(Enchantment.DURABILITY) >= 1) {
+            return true;
+        }
+
         short durabilityLoss = 0;
         short durabilityLoss = 0;
         Material type = inHand.getType();
         Material type = inHand.getType();
 
 

+ 1 - 1
src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java

@@ -243,7 +243,7 @@ public class SkillUtils {
      * @param maxDamageModifier the amount to adjust the max damage by
      * @param maxDamageModifier the amount to adjust the max damage by
      */
      */
     public static void handleDurabilityChange(ItemStack itemStack, double durabilityModifier, double maxDamageModifier) {
     public static void handleDurabilityChange(ItemStack itemStack, double durabilityModifier, double maxDamageModifier) {
-        if (itemStack.hasItemMeta() && itemStack.getItemMeta().isUnbreakable()) {
+        if (itemStack.getEnchantments().get(Enchantment.DURABILITY) != null && itemStack.getEnchantments().get(Enchantment.DURABILITY) >= 1) {
             return;
             return;
         }
         }