diff options
Diffstat (limited to 'src')
3 files changed, 13 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java index 882e39be..cfe5903c 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java +++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java @@ -417,6 +417,8 @@ public class CraftBlockData implements BlockData { } public static CraftBlockData newData(Material material, String data) { + Preconditions.checkArgument(material == null || material.isBlock(), "Cannot get data for not block %s", material); + IBlockData blockData; Block block = CraftMagicNumbers.getBlock(material); diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java index 045b5b41..3474536f 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -84,6 +84,7 @@ public final class CraftMagicNumbers implements UnsafeValues { for (Material material : Material.values()) { MinecraftKey key = key(material); + // TODO: only register if block/item? MATERIAL_ITEM.put(material, Item.REGISTRY.get(key)); MATERIAL_BLOCK.put(material, Block.REGISTRY.get(key)); } diff --git a/src/test/java/org/bukkit/BlockDataTest.java b/src/test/java/org/bukkit/BlockDataTest.java index bd2c249b..e43de765 100644 --- a/src/test/java/org/bukkit/BlockDataTest.java +++ b/src/test/java/org/bukkit/BlockDataTest.java @@ -51,6 +51,16 @@ public class BlockDataTest extends AbstractTestingBase { CraftBlockData.newData(Material.CAKE, cakeTest.toString()); } + @Test(expected = IllegalArgumentException.class) + public void testItem() { + CraftBlockData.newData(Material.DIAMOND_AXE, null); + } + + @Test(expected = IllegalArgumentException.class) + public void testItemParse() { + CraftBlockData.newData(null, "minecraft:diamond_axe"); + } + @Test public void testClone() { Cake cakeTest = (Cake) CraftBlockData.fromData(Blocks.CAKE.getBlockData().set(BlockCake.BITES, 3)); |