Skip to content

Commit

Permalink
Fire NPCTeleportEvent in all cases to allow cancelling
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Apr 13, 2021
1 parent eb4262a commit 979d6f9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions main/src/main/java/net/citizensnpcs/commands/NPCCommands.java
Expand Up @@ -64,6 +64,7 @@
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;
Expand Down Expand Up @@ -2305,6 +2306,10 @@ public void tphere(CommandContext args, CommandSender sender, NPC npc) throws Co
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);
Expand Down

0 comments on commit 979d6f9

Please sign in to comment.