From 3e7fe526815292b256a3e5021d742f3a7f96b2ce Mon Sep 17 00:00:00 2001 From: Minecrell Date: Thu, 9 Jan 2014 16:45:05 +0100 Subject: [PATCH] Correctly modify player sample with hidden player counts. At the moment the setPlayers() method will throw a NullPointerException if the player count has been hidden. This will correctly reset the player counts before setting the player list and return null in the getter instead of throwing an exception. --- .../com/comphenix/protocol/wrappers/WrappedServerPing.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedServerPing.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedServerPing.java index 7dd83966..a783052e 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedServerPing.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/WrappedServerPing.java @@ -241,9 +241,11 @@ public class WrappedServerPing extends AbstractWrapper { /** * Retrieve a copy of all the logged in players. - * @return Logged in players. + * @return Logged in players or NULL if the player count has been hidden via {@link #setPlayersVisible(boolean)}. */ public ImmutableList getPlayers() { + if (players == null) + return null; return ImmutableList.copyOf(PROFILE_CONVERT.getSpecific(PLAYERS_PROFILES.get(players))); } @@ -252,6 +254,8 @@ public class WrappedServerPing extends AbstractWrapper { * @param profile - every logged in player. */ public void setPlayers(Iterable profile) { + if (players == null) + resetPlayers(); PLAYERS_PROFILES.set(players, PROFILE_CONVERT.getGeneric(GameProfile[].class, profile)); }