mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-09 20:30:03 +01:00
Handle NULL results from the deserialization methods.
This commit is contained in:
parent
9448e06ad8
commit
a31dc6fdcb
@ -59,7 +59,10 @@ public class StreamSerializer {
|
|||||||
Object nmsItem = READ_ITEM_METHOD.invoke(null, input);
|
Object nmsItem = READ_ITEM_METHOD.invoke(null, input);
|
||||||
|
|
||||||
// Convert back to a Bukkit item stack
|
// Convert back to a Bukkit item stack
|
||||||
|
if (nmsItem != null)
|
||||||
return MinecraftReflection.getBukkitItemStack(nmsItem);
|
return MinecraftReflection.getBukkitItemStack(nmsItem);
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IOException("Cannot read item stack.", e);
|
throw new IOException("Cannot read item stack.", e);
|
||||||
@ -84,8 +87,14 @@ public class StreamSerializer {
|
|||||||
build());
|
build());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
Object nmsCompound = READ_NBT_METHOD.invoke(null, input);
|
||||||
|
|
||||||
// Convert back to an NBT Compound
|
// 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) {
|
} catch (Exception e) {
|
||||||
throw new IOException("Cannot read item stack.", e);
|
throw new IOException("Cannot read item stack.", e);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user