From b1d149cfd00b5715474feb304d1bbc8fdffa9bd1 Mon Sep 17 00:00:00 2001 From: md_5 Date: Fri, 16 Nov 2018 15:18:28 +1100 Subject: SPIGOT-4489: NOTE_BLOCK incorrectly has BlockStateMeta --- .../bukkit/craftbukkit/inventory/CraftItemFactory.java | 1 - .../org/bukkit/craftbukkit/inventory/CraftItemStack.java | 1 - .../craftbukkit/inventory/CraftMetaBlockState.java | 2 -- .../org/bukkit/craftbukkit/inventory/ItemMetaTest.java | 16 +++++++++------- 4 files changed, 9 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java index 5fc0283b..52041cae 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -199,7 +199,6 @@ public final class CraftItemFactory implements ItemFactory { case DROPPER: case SIGN: case SPAWNER: - case NOTE_BLOCK: case BREWING_STAND: case ENCHANTING_TABLE: case COMMAND_BLOCK: diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java index 1d0580ff..2ef4ac64 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java @@ -461,7 +461,6 @@ public final class CraftItemStack extends ItemStack { case DROPPER: case SIGN: case SPAWNER: - case NOTE_BLOCK: case BREWING_STAND: case ENCHANTING_TABLE: case COMMAND_BLOCK: diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java index ab32666a..0585d240 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java @@ -3,7 +3,6 @@ package org.bukkit.craftbukkit.inventory; import com.google.common.base.Objects; import com.google.common.collect.ImmutableMap; import java.util.Map; -import net.minecraft.server.BlockJukeBox; import net.minecraft.server.EnumColor; import net.minecraft.server.NBTBase; import net.minecraft.server.NBTTagCompound; @@ -175,7 +174,6 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta case DROPPER: case SIGN: case SPAWNER: - case NOTE_BLOCK: case BREWING_STAND: case ENCHANTING_TABLE: case COMMAND_BLOCK: diff --git a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java index d4f8e8c3..65b8123a 100644 --- a/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java +++ b/src/test/java/org/bukkit/craftbukkit/inventory/ItemMetaTest.java @@ -175,21 +175,23 @@ public class ItemMetaTest extends AbstractTestingBase { for (Block block : queue) { if (block != null) { - if (block instanceof ITileEntity) { - ItemStack stack = CraftItemStack.asNewCraftStack(Item.getItemOf(block)); + ItemStack stack = CraftItemStack.asNewCraftStack(Item.getItemOf(block)); - // Command blocks aren't unit testable atm - if (stack.getType() == Material.COMMAND_BLOCK || stack.getType() == Material.CHAIN_COMMAND_BLOCK || stack.getType() == Material.REPEATING_COMMAND_BLOCK) { - return; - } + // Command blocks aren't unit testable atm + if (stack.getType() == Material.COMMAND_BLOCK || stack.getType() == Material.CHAIN_COMMAND_BLOCK || stack.getType() == Material.REPEATING_COMMAND_BLOCK) { + return; + } - ItemMeta meta = stack.getItemMeta(); + ItemMeta meta = stack.getItemMeta(); + if (block instanceof ITileEntity) { assertTrue(stack + " has meta of type " + meta + " expected BlockStateMeta", meta instanceof BlockStateMeta); BlockStateMeta blockState = (BlockStateMeta) meta; assertNotNull(stack + " has null block state", blockState.getBlockState()); blockState.setBlockState(blockState.getBlockState()); + } else { + assertTrue(stack + " has unexpected meta of type BlockStateMeta (but is not a tile)", !(meta instanceof BlockStateMeta)); } } } -- cgit v1.2.3