diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedWatchableObject.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedWatchableObject.java index 9c849efe..0b0b87a2 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedWatchableObject.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedWatchableObject.java @@ -346,6 +346,8 @@ public class WrappedWatchableObject extends AbstractWrapper { return MinecraftReflection.getChunkPositionClass(); else if (wrapped.equals(WrappedChunkCoordinate.class)) return MinecraftReflection.getChunkCoordinatesClass(); + else if (ItemStack.class.isAssignableFrom(wrapped)) + return MinecraftReflection.getItemStackClass(); else return wrapped; } diff --git a/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedWatchableObjectTest.java b/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedWatchableObjectTest.java new file mode 100644 index 00000000..ea1059fd --- /dev/null +++ b/ProtocolLib/src/test/java/com/comphenix/protocol/wrappers/WrappedWatchableObjectTest.java @@ -0,0 +1,31 @@ +package com.comphenix.protocol.wrappers; + +import static org.junit.Assert.*; + +import org.bukkit.Material; +import org.bukkit.craftbukkit.v1_7_R1.inventory.CraftItemFactory; +import org.bukkit.inventory.ItemStack; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.powermock.core.classloader.annotations.PrepareForTest; + +import com.comphenix.protocol.BukkitInitialization; + +@RunWith(org.powermock.modules.junit4.PowerMockRunner.class) +@PrepareForTest(CraftItemFactory.class) +public class WrappedWatchableObjectTest { + @BeforeClass + public static void initializeBukkit() throws IllegalAccessException { + BukkitInitialization.initializeItemMeta(); + } + + @Test + public void testItemStack() { + final ItemStack stack = new ItemStack(Material.GOLD_AXE); + final WrappedWatchableObject test = new WrappedWatchableObject(0, stack); + + ItemStack value = (ItemStack) test.getValue(); + assertEquals(value.getType(), stack.getType()); + } +}