use of org.bukkit.craftbukkit.v.entity.CraftEntity in project Arclight by IzzelAliz.
the class EntityTeleportEventDispatcher method onTeleport.
@SubscribeEvent(receiveCanceled = true)
public void onTeleport(EnderTeleportEvent event) {
if (!(event.getEntity() instanceof EndermanEntity)) {
if (event.getEntity() instanceof ServerPlayerEntity) {
CraftPlayer player = ((ServerPlayerEntityBridge) event.getEntity()).bridge$getBukkitEntity();
PlayerTeleportEvent bukkitEvent = new PlayerTeleportEvent(player, player.getLocation(), new Location(player.getWorld(), event.getTargetX(), event.getTargetY(), event.getTargetZ()), PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
Bukkit.getPluginManager().callEvent(bukkitEvent);
event.setCanceled(bukkitEvent.isCancelled());
event.setTargetX(bukkitEvent.getTo().getX());
event.setTargetY(bukkitEvent.getTo().getY());
event.setTargetZ(bukkitEvent.getTo().getZ());
} else {
CraftEntity entity = ((EntityBridge) event.getEntity()).bridge$getBukkitEntity();
EntityTeleportEvent bukkitEvent = new EntityTeleportEvent(entity, entity.getLocation(), new Location(entity.getWorld(), event.getTargetX(), event.getTargetY(), event.getTargetZ()));
Bukkit.getPluginManager().callEvent(bukkitEvent);
event.setCanceled(bukkitEvent.isCancelled());
event.setTargetX(bukkitEvent.getTo().getX());
event.setTargetY(bukkitEvent.getTo().getY());
event.setTargetZ(bukkitEvent.getTo().getZ());
}
}
}
Aggregations