diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftEvil.java b/src/main/java/org/bukkit/craftbukkit/util/CraftEvil.java index db77fbe71c..1580db8362 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftEvil.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftEvil.java @@ -22,6 +22,10 @@ public class CraftEvil { static { for (Material material : Material.values()) { + if (!material.isLegacy()) { + continue; + } + Preconditions.checkState(!byId.containsKey(material.getId()), "Duplicate material ID for", material); byId.put(material.getId(), material); } diff --git a/src/test/java/org/bukkit/EvilTest.java b/src/test/java/org/bukkit/EvilTest.java new file mode 100644 index 0000000000..39c6cb26d0 --- /dev/null +++ b/src/test/java/org/bukkit/EvilTest.java @@ -0,0 +1,23 @@ +package org.bukkit; + +import org.bukkit.craftbukkit.util.CraftEvil; +import org.junit.Assert; +import org.junit.Test; + +public class EvilTest { + + @Test + public void testFrom() { + Assert.assertEquals(Material.LEGACY_STONE, CraftEvil.getMaterial(1)); + } + + @Test + public void testTo() { + Assert.assertEquals(1, CraftEvil.getId(Material.LEGACY_STONE)); + } + + @Test(expected = IllegalArgumentException.class) + public void testIllegal() { + Material.STONE.getId(); + } +}