From c6e917d243361dd38fd4ccbdc7c34a24078c3fb2 Mon Sep 17 00:00:00 2001 From: aPunch Date: Sun, 26 Feb 2012 00:35:44 -0600 Subject: [PATCH] attempt to fix more world issues --- src/net/citizensnpcs/EventListen.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/net/citizensnpcs/EventListen.java b/src/net/citizensnpcs/EventListen.java index e87171967..38b488251 100644 --- a/src/net/citizensnpcs/EventListen.java +++ b/src/net/citizensnpcs/EventListen.java @@ -10,11 +10,14 @@ import net.citizensnpcs.api.npc.NPC; import net.citizensnpcs.api.trait.trait.Owner; import net.citizensnpcs.api.trait.trait.SpawnLocation; import net.citizensnpcs.npc.CitizensNPCManager; +import net.citizensnpcs.resource.lib.EntityHumanNPC; import net.citizensnpcs.util.Messaging; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -22,6 +25,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent.TargetReason; +import org.bukkit.event.player.PlayerChangedWorldEvent; import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkUnloadEvent; @@ -156,4 +160,13 @@ public class EventListen implements Listener { Bukkit.getPluginManager().callEvent( new EntityTargetEvent(event.getRightClicked(), event.getPlayer(), TargetReason.CUSTOM)); } + + @EventHandler + public void onPlayerChangedWorld(PlayerChangedWorldEvent event) { + if (!(((CraftPlayer) event.getPlayer()).getHandle() instanceof EntityHumanNPC)) + return; + + ((CraftServer) Bukkit.getServer()).getHandle().players.remove(((CraftPlayer) event.getPlayer()).getHandle()); + } + } \ No newline at end of file