From dd5bfd5f168c7be39c5432a6fc6e893e1688b554 Mon Sep 17 00:00:00 2001 From: Mark Hendriks Date: Fri, 9 Jan 2015 01:45:17 +0100 Subject: [PATCH] Fix NPE when writing PlayerInfoData to packet By default, the listName field in EntityPlayer is null. As the WrappedChatComponent ignores null values (which in itself is completely fine), the field will be null when you read one while the EntityPlayer has no listName. When you try to write one, however, the converter directly accesses the handle from the WrappedChatComponent. This means you will be trying to access the handle of null when you don't explicitly set the displayName in such a packet. --- .../java/com/comphenix/protocol/wrappers/PlayerInfoData.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/PlayerInfoData.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/PlayerInfoData.java index 6974a620..8bad0b9d 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/PlayerInfoData.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/PlayerInfoData.java @@ -80,7 +80,7 @@ public class PlayerInfoData { specific.profile.handle, specific.ping, EnumWrappers.getGameModeConverter().getGeneric(EnumWrappers.getGameModeClass(), specific.gameMode), - specific.displayName.handle + specific.displayName != null ? specific.displayName.handle : null ); return result; } catch (Exception e) { @@ -149,4 +149,4 @@ public class PlayerInfoData { return String.format("PlayerInfoData { profile=%s, ping=%s, gameMode=%s, displayName=%s }", profile, ping, gameMode, displayName); } -} \ No newline at end of file +}