diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java index 44b88b3237..f617e9e2ea 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftArt.java @@ -5,6 +5,7 @@ import org.bukkit.Art; // Safety class, will break if either side changes public class CraftArt { + public static Art NotchToBukkit(EnumArt art) { switch (art) { case KEBAB: return Art.KEBAB; @@ -32,8 +33,10 @@ public class CraftArt { case BURNINGSKULL: return Art.BURNINGSKULL; case SKELETON: return Art.SKELETON; case DONKEYKONG: return Art.DONKEYKONG; + case WITHER: return Art.WITHER; + default: + throw new AssertionError(art); } - return null; } public static EnumArt BukkitToNotch(Art art) { @@ -63,12 +66,9 @@ public class CraftArt { case BURNINGSKULL: return EnumArt.BURNINGSKULL; case SKELETON: return EnumArt.SKELETON; case DONKEYKONG: return EnumArt.DONKEYKONG; + case WITHER: return EnumArt.WITHER; + default: + throw new AssertionError(art); } - return null; - } - - static { - assert (EnumArt.values().length == 25); - assert (Art.values().length == 25); } } diff --git a/paper-server/src/test/java/org/bukkit/ArtTest.java b/paper-server/src/test/java/org/bukkit/ArtTest.java index 6a9774f104..cca4ddf2f1 100644 --- a/paper-server/src/test/java/org/bukkit/ArtTest.java +++ b/paper-server/src/test/java/org/bukkit/ArtTest.java @@ -5,10 +5,13 @@ import static org.hamcrest.Matchers.hasSize; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; +import java.util.EnumMap; import java.util.List; +import java.util.Map; import net.minecraft.server.EnumArt; +import org.bukkit.craftbukkit.CraftArt; import org.junit.Test; import com.google.common.collect.Lists; @@ -40,4 +43,24 @@ public class ArtTest { assertThat("org.bukkit.Art has too many arts", arts, hasSize(0)); } + + @Test + public void testCraftArtToNotch() { + Map cache = new EnumMap(EnumArt.class); + for (Art art : Art.values()) { + EnumArt enumArt = CraftArt.BukkitToNotch(art); + assertNotNull(art.name(), enumArt); + assertThat(art.name(), cache.put(enumArt, art), is((Art) null)); + } + } + + @Test + public void testCraftArtToBukkit() { + Map cache = new EnumMap(Art.class); + for (EnumArt enumArt : EnumArt.values()) { + Art art = CraftArt.NotchToBukkit(enumArt); + assertNotNull(enumArt.name(), art); + assertThat(enumArt.name(), cache.put(art, enumArt), is((EnumArt) null)); + } + } }