mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-23 11:05:49 +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.CommandSenderCloneNPCEvent;
|
||||||
import net.citizensnpcs.api.event.CommandSenderCreateNPCEvent;
|
import net.citizensnpcs.api.event.CommandSenderCreateNPCEvent;
|
||||||
import net.citizensnpcs.api.event.DespawnReason;
|
import net.citizensnpcs.api.event.DespawnReason;
|
||||||
|
import net.citizensnpcs.api.event.NPCTeleportEvent;
|
||||||
import net.citizensnpcs.api.event.PlayerCloneNPCEvent;
|
import net.citizensnpcs.api.event.PlayerCloneNPCEvent;
|
||||||
import net.citizensnpcs.api.event.PlayerCreateNPCEvent;
|
import net.citizensnpcs.api.event.PlayerCreateNPCEvent;
|
||||||
import net.citizensnpcs.api.event.SpawnReason;
|
import net.citizensnpcs.api.event.SpawnReason;
|
||||||
@ -2305,6 +2306,10 @@ public class NPCCommands {
|
|||||||
to.setZ(to.getZ() + 0.5);
|
to.setZ(to.getZ() + 0.5);
|
||||||
}
|
}
|
||||||
if (!npc.isSpawned()) {
|
if (!npc.isSpawned()) {
|
||||||
|
NPCTeleportEvent event = new NPCTeleportEvent(npc, to);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (event.isCancelled())
|
||||||
|
return;
|
||||||
npc.spawn(to, SpawnReason.COMMAND);
|
npc.spawn(to, SpawnReason.COMMAND);
|
||||||
} else {
|
} else {
|
||||||
npc.teleport(to, TeleportCause.COMMAND);
|
npc.teleport(to, TeleportCause.COMMAND);
|
||||||
|
Loading…
Reference in New Issue
Block a user