From 9c02c121791427c4608af3fab36d4c01a4ed8faa Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 8 Jul 2016 12:51:32 +1000 Subject: [PATCH] SPIGOT-2481: Implement EnchantmentTarget.BREAKABLE --- .../craftbukkit/enchantments/CraftEnchantment.java | 2 ++ src/test/java/org/bukkit/PerMaterialTest.java | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java index a103e56096..12337bf17a 100644 --- a/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java +++ b/src/main/java/org/bukkit/craftbukkit/enchantments/CraftEnchantment.java @@ -47,6 +47,8 @@ public class CraftEnchantment extends Enchantment { return EnchantmentTarget.BOW; case FISHING_ROD: return EnchantmentTarget.FISHING_ROD; + case BREAKABLE: + return EnchantmentTarget.BREAKABLE; default: return null; } diff --git a/src/test/java/org/bukkit/PerMaterialTest.java b/src/test/java/org/bukkit/PerMaterialTest.java index b727d1d4c2..60665f539f 100644 --- a/src/test/java/org/bukkit/PerMaterialTest.java +++ b/src/test/java/org/bukkit/PerMaterialTest.java @@ -27,6 +27,7 @@ import java.util.Map; import net.minecraft.server.Block; import net.minecraft.server.Blocks; import org.bukkit.craftbukkit.util.CraftMagicNumbers; +import org.bukkit.enchantments.EnchantmentTarget; @RunWith(Parameterized.class) public class PerMaterialTest extends AbstractTestingBase { @@ -146,4 +147,13 @@ public class PerMaterialTest extends AbstractTestingBase { assertFalse(material.hasGravity()); } } + + @Test + public void usesDurability() { + if (!material.isBlock()) { + assertThat(EnchantmentTarget.BREAKABLE.includes(material), is(CraftMagicNumbers.getItem(material).usesDurability())); + } else { + assertFalse(EnchantmentTarget.BREAKABLE.includes(material)); + } + } }