From 3783328cb1b995c727877c9448e6512e52108e68 Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Tue, 18 Sep 2012 02:16:11 +0200 Subject: [PATCH] Forgot to convert the types to NMS. --- .../protocol/injector/PacketConstructor.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/PacketConstructor.java b/ProtocolLib/src/com/comphenix/protocol/injector/PacketConstructor.java index 048f77d6..38325df4 100644 --- a/ProtocolLib/src/com/comphenix/protocol/injector/PacketConstructor.java +++ b/ProtocolLib/src/com/comphenix/protocol/injector/PacketConstructor.java @@ -77,13 +77,14 @@ public class PacketConstructor { */ public PacketConstructor withPacket(int id, Class[] types) { - for (Unwrapper unwrapper : unwrappers) { - for (int i = 0; i < types.length; i++) { + for (int i = 0; i < types.length; i++) { + for (Unwrapper unwrapper : unwrappers) { Class result = unwrapper.unwrapType(types[i]); // Update type we're searching for if (result != null) { types[i] = result; + break; } } } @@ -117,6 +118,18 @@ public class PacketConstructor { public PacketContainer createPacket(Object... values) throws FieldAccessException { try { + // Convert types + for (int i = 0; i < values.length; i++) { + for (Unwrapper unwrapper : unwrappers) { + Object converted = unwrapper.unwrapItem(values[i]); + + if (converted != null) { + values[i] = converted; + break; + } + } + } + Packet nmsPacket = (Packet) constructorMethod.newInstance(values); return new PacketContainer(packetID, nmsPacket);