13
0
geforkt von Mirrors/Paper

SPIGOT-4399: Add attribute modifier equality test

Dieser Commit ist enthalten in:
Nathan Wolf 2018-09-26 17:21:53 -07:00 committet von md_5
Ursprung 5ee1c18a4b
Commit 116cb9a1bc

Datei anzeigen

@ -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);