From b0f7fb4348dce046d2b65dc638af7811db3ae5b9 Mon Sep 17 00:00:00 2001 From: Morphan1 Date: Tue, 10 Mar 2015 03:40:25 -0400 Subject: [PATCH] Make some minor adjustments --- src/main/java/net/citizensnpcs/EventListen.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/citizensnpcs/EventListen.java b/src/main/java/net/citizensnpcs/EventListen.java index 44a900004..74fe96e5e 100644 --- a/src/main/java/net/citizensnpcs/EventListen.java +++ b/src/main/java/net/citizensnpcs/EventListen.java @@ -283,24 +283,27 @@ public class EventListen implements Listener { new BukkitRunnable() { @Override public void run() { - Player player = event.getPlayer(); + final Player player = event.getPlayer(); + if (player == null || !player.isValid()) + return; for (Entity entity : player.getNearbyEntities(72, 72, 72)) { if (entity instanceof Player && npcRegistry.isNPC(entity)) { - final EntityPlayer entityplayer = ((CraftPlayer) player).getHandle(); final EntityPlayer entitynpc = ((CraftPlayer) entity).getHandle(); - entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo( + NMS.sendPacket(player, new PacketPlayOutPlayerInfo( PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entitynpc)); new BukkitRunnable() { @Override public void run() { - entityplayer.playerConnection.sendPacket(new PacketPlayOutPlayerInfo( + if (!player.isValid()) + return; + NMS.sendPacket(player, new PacketPlayOutPlayerInfo( PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entitynpc)); } }.runTaskLater(CitizensAPI.getPlugin(), 2); } } } - }.runTaskLater(CitizensAPI.getPlugin(), 30); + }.runTaskLater(CitizensAPI.getPlugin(), 40); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)