From 8c8ca3746b26ddf95f1800b2e890fb81ab5e84ed Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Sun, 10 Nov 2013 20:47:32 +0100 Subject: [PATCH] Correctly wrap and unwrap ItemStacks in WrappedWatchableObject. This should make it possible to set and retrieve watchable objects of the type ItemStack. --- .../protocol/wrappers/WrappedWatchableObject.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 1ef3de0f..03ccbb74 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedWatchableObject.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedWatchableObject.java @@ -280,6 +280,8 @@ public class WrappedWatchableObject { return ChunkPosition.class; else if (unwrapped.equals(MinecraftReflection.getChunkCoordinatesClass())) return WrappedChunkCoordinate.class; + else if (unwrapped.equals(MinecraftReflection.getItemStackClass())) + return ItemStack.class; else return unwrapped; } @@ -291,7 +293,10 @@ public class WrappedWatchableObject { */ static Object getUnwrapped(Object wrapped) { // Convert special cases - if (wrapped instanceof WrappedChunkCoordinate) + if (wrapped instanceof ChunkPosition) + return ChunkPosition.getConverter().getGeneric( + MinecraftReflection.getChunkPositionClass(), (ChunkPosition) wrapped); + else if (wrapped instanceof WrappedChunkCoordinate) return ((WrappedChunkCoordinate) wrapped).getHandle(); else if (wrapped instanceof ItemStack) return BukkitConverters.getItemStackConverter().getGeneric(