From a31dc6fdcbc1a8a776399c20dc0b7a9b1adfb723 Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Wed, 17 Jul 2013 21:31:44 +0200 Subject: [PATCH] Handle NULL results from the deserialization methods. --- .../protocol/utility/StreamSerializer.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/StreamSerializer.java b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/StreamSerializer.java index 60d898ce..6c0b9d8a 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/utility/StreamSerializer.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/utility/StreamSerializer.java @@ -59,7 +59,10 @@ public class StreamSerializer { Object nmsItem = READ_ITEM_METHOD.invoke(null, input); // Convert back to a Bukkit item stack - return MinecraftReflection.getBukkitItemStack(nmsItem); + if (nmsItem != null) + return MinecraftReflection.getBukkitItemStack(nmsItem); + else + return null; } catch (Exception e) { throw new IOException("Cannot read item stack.", e); @@ -84,8 +87,14 @@ public class StreamSerializer { build()); } try { + Object nmsCompound = READ_NBT_METHOD.invoke(null, input); + // Convert back to an NBT Compound - return NbtFactory.fromNMSCompound(READ_NBT_METHOD.invoke(null, input)); + if (nmsCompound != null) + return NbtFactory.fromNMSCompound(nmsCompound); + else + return null; + } catch (Exception e) { throw new IOException("Cannot read item stack.", e); }