mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-23 02:55:45 +01:00
Fire NPCTeleportEvent in all cases to allow cancelling
This commit is contained in:
parent
eb4262a80f
commit
979d6f95fa
@ -64,6 +64,7 @@ import net.citizensnpcs.api.command.exception.ServerCommandException;
|
||||
import net.citizensnpcs.api.event.CommandSenderCloneNPCEvent;
|
||||
import net.citizensnpcs.api.event.CommandSenderCreateNPCEvent;
|
||||
import net.citizensnpcs.api.event.DespawnReason;
|
||||
import net.citizensnpcs.api.event.NPCTeleportEvent;
|
||||
import net.citizensnpcs.api.event.PlayerCloneNPCEvent;
|
||||
import net.citizensnpcs.api.event.PlayerCreateNPCEvent;
|
||||
import net.citizensnpcs.api.event.SpawnReason;
|
||||
@ -2305,6 +2306,10 @@ public class NPCCommands {
|
||||
to.setZ(to.getZ() + 0.5);
|
||||
}
|
||||
if (!npc.isSpawned()) {
|
||||
NPCTeleportEvent event = new NPCTeleportEvent(npc, to);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
npc.spawn(to, SpawnReason.COMMAND);
|
||||
} else {
|
||||
npc.teleport(to, TeleportCause.COMMAND);
|
||||
|
Loading…
Reference in New Issue
Block a user