call event elsewhere

This commit is contained in:
aPunch 2012-01-14 17:58:47 -06:00
parent 32abcf8a79
commit 456c9bfceb
2 changed files with 3 additions and 4 deletions

View File

@ -4,6 +4,7 @@ import java.util.HashSet;
import java.util.Set;
import net.citizensnpcs.api.Citizens;
import net.citizensnpcs.api.event.NPCDespawnEvent;
import net.citizensnpcs.api.event.NPCSpawnEvent;
import net.citizensnpcs.api.npc.trait.Character;
import net.citizensnpcs.api.npc.NPC;
@ -113,6 +114,8 @@ public class CitizensNPC implements NPC {
@Override
public void despawn() {
Bukkit.getPluginManager().callEvent(new NPCDespawnEvent(this));
mcEntity.die();
((CitizensNPCManager) Citizens.getNPCManager()).despawn(this);
}

View File

@ -6,7 +6,6 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.World;
@ -15,7 +14,6 @@ import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.entity.LivingEntity;
import net.citizensnpcs.api.Citizens;
import net.citizensnpcs.api.event.NPCDespawnEvent;
import net.citizensnpcs.api.npc.NPC;
import net.citizensnpcs.api.npc.NPCManager;
import net.citizensnpcs.api.npc.trait.Character;
@ -109,8 +107,6 @@ public class CitizensNPCManager implements NPCManager {
}
public void despawn(NPC npc) {
Bukkit.getPluginManager().callEvent(new NPCDespawnEvent(npc));
CraftNPC mcEntity = ((CitizensNPC) npc).getHandle();
getWorldServer(((LocationTrait) npc.getTrait("location")).getLocation().getWorld()).removeEntity(mcEntity);
spawned.remove(mcEntity.getPlayer());