summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Wolf <nathan@elmakers.com>2018-09-26 17:21:53 -0700
committermd_5 <git@md-5.net>2018-09-27 20:56:49 +1000
commit116cb9a1bce6b0aa51132be2950b1e6c6ecf73a0 (patch)
tree169f090d29630a73743327c797aba9a142c655d3
parent5ee1c18a4bfc72721568bee384b7f8161a515f00 (diff)
downloadcraftbukkit-116cb9a1bce6b0aa51132be2950b1e6c6ecf73a0.tar
craftbukkit-116cb9a1bce6b0aa51132be2950b1e6c6ecf73a0.tar.gz
craftbukkit-116cb9a1bce6b0aa51132be2950b1e6c6ecf73a0.tar.lz
craftbukkit-116cb9a1bce6b0aa51132be2950b1e6c6ecf73a0.tar.xz
craftbukkit-116cb9a1bce6b0aa51132be2950b1e6c6ecf73a0.zip
SPIGOT-4399: Add attribute modifier equality test
-rw-r--r--src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java24
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);