mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-24 11:38:26 +01:00
Call onRemove
This commit is contained in:
parent
091ce13cca
commit
d442da91fb
@ -17,6 +17,7 @@ import net.citizensnpcs.api.npc.NPCRegistry;
|
||||
import net.citizensnpcs.api.scripting.EventRegistrar;
|
||||
import net.citizensnpcs.api.scripting.ObjectProvider;
|
||||
import net.citizensnpcs.api.scripting.ScriptCompiler;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.api.trait.TraitFactory;
|
||||
import net.citizensnpcs.command.CommandContext;
|
||||
import net.citizensnpcs.command.CommandManager;
|
||||
@ -73,6 +74,8 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
while (itr.hasNext()) {
|
||||
NPC npc = itr.next();
|
||||
npc.despawn();
|
||||
for (Trait t : npc.getTraits())
|
||||
t.onRemove();
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
|
@ -705,7 +705,7 @@ public class NPCCommands {
|
||||
if (!npc.isSpawned())
|
||||
npc.spawn(npc.getTrait(CurrentLocation.class).getLocation());
|
||||
player.teleport(npc.getBukkitEntity(), TeleportCause.COMMAND);
|
||||
Messaging.sendTr(player, Messages.TELEPORTED_TO_NPC);
|
||||
Messaging.sendTr(player, Messages.TELEPORTED_TO_NPC, npc.getName());
|
||||
}
|
||||
|
||||
@Command(aliases = { "npc" }, usage = "tphere", desc = "Teleport a NPC to your location", modifiers = {
|
||||
|
@ -89,7 +89,7 @@ public abstract class CitizensNPC extends AbstractNPC {
|
||||
if (hasTrait(clazz)) {
|
||||
trait = getTrait(clazz);
|
||||
} else {
|
||||
trait = CitizensAPI.getTraitFactory().getTrait(traitKey.name());
|
||||
trait = CitizensAPI.getTraitFactory().getTrait(clazz);
|
||||
if (trait == null) {
|
||||
Messaging.severeTr(Messages.SKIPPING_BROKEN_TRAIT, traitKey.name(), getId());
|
||||
continue;
|
||||
|
@ -7,6 +7,7 @@ import java.util.Map;
|
||||
import net.citizensnpcs.NPCDataStore;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.npc.ai.NPCHolder;
|
||||
import net.citizensnpcs.npc.entity.CitizensBlazeNPC;
|
||||
import net.citizensnpcs.npc.entity.CitizensCaveSpiderNPC;
|
||||
@ -104,6 +105,8 @@ public class CitizensNPCRegistry implements NPCRegistry {
|
||||
NPC npc = itr.next();
|
||||
itr.remove();
|
||||
npc.despawn();
|
||||
for (Trait t : npc.getTraits())
|
||||
t.onRemove();
|
||||
saves.remove(npc);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user