diff options
-rw-r--r-- | src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java index 00f89f22..d4f8e8c3 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java @@ -6,6 +6,8 @@ import static org.hamcrest.Matchers.*; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.UUID; + import net.minecraft.server.Block; import net.minecraft.server.IRegistry; import net.minecraft.server.ITileEntity; @@ -21,6 +23,8 @@ import org.bukkit.FireworkEffect; import org.bukkit.Material; import org.bukkit.FireworkEffect.Type; import org.bukkit.NamespacedKey; +import org.bukkit.attribute.Attribute; +import org.bukkit.attribute.AttributeModifier; import org.bukkit.block.banner.Pattern; import org.bukkit.block.banner.PatternType; import org.bukkit.craftbukkit.inventory.ItemStackTest.StackProvider; @@ -320,6 +324,26 @@ public class ItemMetaTest extends AbstractTestingBase { } } + @Test + public void testAttributeModifiers() { + UUID sameUUID = UUID.randomUUID(); + ItemMeta itemMeta = Bukkit.getItemFactory().getItemMeta(Material.DIAMOND_PICKAXE); + itemMeta.addAttributeModifier(Attribute.GENERIC_ATTACK_SPEED, new AttributeModifier(sameUUID, "Test Modifier", 10, AttributeModifier.Operation.ADD_NUMBER)); + + ItemMeta equalMeta = Bukkit.getItemFactory().getItemMeta(Material.DIAMOND_PICKAXE); + equalMeta.addAttributeModifier(Attribute.GENERIC_ATTACK_SPEED, new AttributeModifier(sameUUID, "Test Modifier", 10, AttributeModifier.Operation.ADD_NUMBER)); + + assertThat(itemMeta.equals(equalMeta), is(true)); + + ItemMeta itemMeta2 = Bukkit.getItemFactory().getItemMeta(Material.DIAMOND_PICKAXE); + itemMeta2.addAttributeModifier(Attribute.GENERIC_ATTACK_SPEED, new AttributeModifier(sameUUID, "Test Modifier", 10, AttributeModifier.Operation.ADD_NUMBER)); + + ItemMeta notEqualMeta2 = Bukkit.getItemFactory().getItemMeta(Material.DIAMOND_PICKAXE); + notEqualMeta2.addAttributeModifier(Attribute.GENERIC_ATTACK_SPEED, new AttributeModifier(sameUUID, "Test Modifier", 11, AttributeModifier.Operation.ADD_NUMBER)); + + assertThat(itemMeta2.equals(notEqualMeta2), is(false)); + } + private void downCastTest(final StackWrapper provider) { final String name = provider.toString(); final ItemStack blank = new ItemStack(Material.STONE); |