summaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java47
1 files changed, 47 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 b59b36a9..abf84ed6 100644
--- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java
+++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java
@@ -21,6 +21,7 @@ import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.bukkit.inventory.meta.FireworkEffectMeta;
import org.bukkit.inventory.meta.FireworkMeta;
+import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.MapMeta;
import org.bukkit.inventory.meta.PotionMeta;
@@ -62,6 +63,52 @@ public class ItemMetaTest extends AbstractTestingBase {
}
}
+ @Test
+ public void testConflictingEnchantment() {
+ ItemMeta itemMeta = Bukkit.getItemFactory().getItemMeta(Material.DIAMOND_PICKAXE);
+ assertThat(itemMeta.hasConflictingEnchant(Enchantment.DURABILITY), is(false));
+
+ itemMeta.addEnchant(Enchantment.SILK_TOUCH, 1, false);
+ assertThat(itemMeta.hasConflictingEnchant(Enchantment.DURABILITY), is(false));
+ assertThat(itemMeta.hasConflictingEnchant(Enchantment.LOOT_BONUS_BLOCKS), is(true));
+ assertThat(itemMeta.hasConflictingEnchant(null), is(false));
+ }
+
+ @Test
+ public void testConflictingStoredEnchantment() {
+ EnchantmentStorageMeta itemMeta = (EnchantmentStorageMeta) Bukkit.getItemFactory().getItemMeta(Material.ENCHANTED_BOOK);
+ assertThat(itemMeta.hasConflictingStoredEnchant(Enchantment.DURABILITY), is(false));
+
+ itemMeta.addStoredEnchant(Enchantment.SILK_TOUCH, 1, false);
+ assertThat(itemMeta.hasConflictingStoredEnchant(Enchantment.DURABILITY), is(false));
+ assertThat(itemMeta.hasConflictingStoredEnchant(Enchantment.LOOT_BONUS_BLOCKS), is(true));
+ assertThat(itemMeta.hasConflictingStoredEnchant(null), is(false));
+ }
+
+ @Test
+ public void testConflictingEnchantments() {
+ ItemMeta itemMeta = Bukkit.getItemFactory().getItemMeta(Material.DIAMOND_PICKAXE);
+ itemMeta.addEnchant(Enchantment.DURABILITY, 6, true);
+ itemMeta.addEnchant(Enchantment.DIG_SPEED, 6, true);
+ assertThat(itemMeta.hasConflictingEnchant(Enchantment.LOOT_BONUS_BLOCKS), is(false));
+
+ itemMeta.addEnchant(Enchantment.SILK_TOUCH, 1, false);
+ assertThat(itemMeta.hasConflictingEnchant(Enchantment.LOOT_BONUS_BLOCKS), is(true));
+ assertThat(itemMeta.hasConflictingEnchant(null), is(false));
+ }
+
+ @Test
+ public void testConflictingStoredEnchantments() {
+ EnchantmentStorageMeta itemMeta = (EnchantmentStorageMeta) Bukkit.getItemFactory().getItemMeta(Material.ENCHANTED_BOOK);
+ itemMeta.addStoredEnchant(Enchantment.DURABILITY, 6, true);
+ itemMeta.addStoredEnchant(Enchantment.DIG_SPEED, 6, true);
+ assertThat(itemMeta.hasConflictingStoredEnchant(Enchantment.LOOT_BONUS_BLOCKS), is(false));
+
+ itemMeta.addStoredEnchant(Enchantment.SILK_TOUCH, 1, false);
+ assertThat(itemMeta.hasConflictingStoredEnchant(Enchantment.LOOT_BONUS_BLOCKS), is(true));
+ assertThat(itemMeta.hasConflictingStoredEnchant(null), is(false));
+ }
+
private static FireworkMeta newFireworkMeta() {
return ((FireworkMeta) Bukkit.getItemFactory().getItemMeta(Material.FIREWORK));
}