diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 71c3ea75b8..0ad2920f3e 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -443,6 +443,8 @@ public class CraftWorld implements World { // Forces the client to update to the new time immediately for (Player p : getPlayers()) { CraftPlayer cp = (CraftPlayer) p; + if (cp.getHandle().netServerHandler == null) continue; + cp.getHandle().netServerHandler.sendPacket(new Packet4UpdateTime(cp.getHandle().getPlayerTime())); } } @@ -767,6 +769,8 @@ public class CraftWorld implements World { radius *= radius; for (Player player : getPlayers()) { + if (((CraftPlayer) player).getHandle().netServerHandler == null) continue; + distance = (int) player.getLocation().distanceSquared(location); if (distance <= radius) { ((CraftPlayer) player).getHandle().netServerHandler.sendPacket(packet); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index 10020c1dbc..a50df490b5 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -221,6 +221,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { } private void openCustomInventory(Inventory inventory, EntityPlayer player, int windowType) { + if (player.netServerHandler == null) return; Container container = new CraftContainer(inventory, this, player.nextContainerCounter()); container = CraftEventFactory.callInventoryOpenEvent(player, container); @@ -270,6 +271,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { public void openInventory(InventoryView inventory) { if (!(getHandle() instanceof EntityPlayer)) return; // TODO: NPC support? + if (((EntityPlayer) getHandle()).netServerHandler == null) return; if (getHandle().activeContainer != getHandle().defaultContainer) { // fire INVENTORY_CLOSE if one already open ((EntityPlayer)getHandle()).netServerHandler.handleContainerClose(new Packet101CloseWindow(getHandle().activeContainer.windowId)); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index 4d071841fa..c00d8d63e1 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -240,7 +240,8 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { getHandle().effects.remove(type.getId()); getHandle().e = true; // Should be called updateEffects if (getHandle() instanceof EntityPlayer) { - ((EntityPlayer)getHandle()).netServerHandler.sendPacket(new Packet42RemoveMobEffect(getHandle().id, new MobEffect(type.getId(), 0, 0))); + if (((EntityPlayer) getHandle()).netServerHandler == null) return; + ((EntityPlayer) getHandle()).netServerHandler.sendPacket(new Packet42RemoveMobEffect(getHandle().id, new MobEffect(type.getId(), 0, 0))); } } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index ec269fcbc1..080a687559 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -178,6 +178,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { Packet201PlayerInfo packet = new Packet201PlayerInfo(name, true, getHandle().ping); for (int i = 0; i < server.getHandle().players.size(); ++i) { EntityPlayer entityplayer = (EntityPlayer) server.getHandle().players.get(i); + if (entityplayer.netServerHandler == null) continue; if (entityplayer.getBukkitEntity().canSee(this)) { entityplayer.netServerHandler.sendPacket(oldpacket); @@ -587,6 +588,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void hidePlayer(Player player) { Validate.notNull(player, "hidden player cannot be null"); + if (getHandle().netServerHandler == null) return; if (equals(player)) return; if (hiddenPlayers.containsKey(player.getName())) return; hiddenPlayers.put(player.getName(), player); @@ -605,6 +607,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void showPlayer(Player player) { Validate.notNull(player, "shown player cannot be null"); + if (getHandle().netServerHandler == null) return; if (equals(player)) return; if (!hiddenPlayers.containsKey(player.getName())) return; hiddenPlayers.remove(player.getName()); @@ -732,6 +735,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { public void sendPluginMessage(Plugin source, String channel, byte[] message) { StandardMessenger.validatePluginMessage(server.getMessenger(), source, channel, message); + if (getHandle().netServerHandler == null) return; if (channels.contains(channel)) { Packet250CustomPayload packet = new Packet250CustomPayload(); @@ -755,6 +759,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { } public void sendSupportedChannels() { + if (getHandle().netServerHandler == null) return; Set listening = server.getMessenger().getIncomingChannels(); if (!listening.isEmpty()) {