From 9c12dc0ef8fa1310452d8f51f3e7194072e08df6 Mon Sep 17 00:00:00 2001 From: Travis Watkins Date: Tue, 24 Apr 2012 12:25:07 -0500 Subject: [PATCH] Fix potential NPE in vanish API. Fixes BUKKIT-1541 --- .../java/org/bukkit/craftbukkit/entity/CraftPlayer.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 1a60588092..208e162274 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -596,6 +596,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (hiddenPlayers.containsKey(player.getName())) return; hiddenPlayers.put(player.getName(), player); + if (getHandle().netServerHandler == null) { + return; + } + //remove this player from the hidden player's EntityTrackerEntry EntityTracker tracker = ((WorldServer) entity.world).tracker; EntityPlayer other = ((CraftPlayer) player).getHandle(); @@ -614,6 +618,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player { if (!hiddenPlayers.containsKey(player.getName())) return; hiddenPlayers.remove(player.getName()); + if (getHandle().netServerHandler == null) { + return; + } + EntityTracker tracker = ((WorldServer) entity.world).tracker; EntityPlayer other = ((CraftPlayer) player).getHandle(); EntityTrackerEntry entry = (EntityTrackerEntry) tracker.trackedEntities.get(other.id);