/** * Teleport an entity and the vehicle it is inside of, or vice versa. * * @param entity The entity/vehicle to be teleported. * @param to The destination. */ public static void teleport(final Entity entity, final Location to) { EntityTeleportEvent event = new EntityTeleportEvent(entity, entity.getLocation(), to); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) return; if (entity.isInsideVehicle()) { Entity vehicle = entity.getVehicle(); vehicle.eject(); vehicle.teleport(to); entity.teleport(to); vehicle.setPassenger(entity); } else if (entity.getPassenger() != null) { Entity passenger = entity.getPassenger(); entity.eject(); entity.teleport(to); passenger.teleport(to); entity.setPassenger(passenger); } else entity.teleport(to); }
/** * Teleport an entity and the vehicle it is inside of, or vice versa. * * @param entity The entity/vehicle to be teleported. * @param to The destination. */ public static void teleport(final Entity entity, final Location to) { EntityTeleportEvent event = new EntityTeleportEvent(entity, entity.getLocation(), to); Bukkit.getPluginManager().callEvent(event); if (event.isCancelled()) return; if (entity.isInsideVehicle()) { Entity vehicle = entity.getVehicle(); vehicle.eject(); vehicle.teleport(to); entity.teleport(to); vehicle.setPassenger(entity); } else if (entity.getPassenger() != null) { Entity passenger = entity.getPassenger(); entity.eject(); entity.teleport(to); passenger.teleport(to); entity.setPassenger(passenger); } else { entity.teleport(to); } }
@Override protected Location[] get(Event event) { if (event instanceof PlayerTeleportEvent) { return new Location[]{((PlayerTeleportEvent) event).getTo()}; } else if (event instanceof EntityTeleportEvent) { return new Location[]{((EntityTeleportEvent) event).getTo()}; } throw new IllegalArgumentException("The event " + event + " should be a PlayerTeleportEvent or EntityTeleportEvent!"); }
@Override public boolean init(Expression<?>[] expressions, int i, Kleenean kleenean, SkriptParser.ParseResult parseResult) { if (!ScriptLoader.isCurrentEvent(PlayerTeleportEvent.class, EntityTeleportEvent.class)) { Skript.error("'destination' can only be used in an 'on teleport' event!"); return false; } return true; }
@Override public void change(Event event, Object[] delta, Changer.ChangeMode mode) { Location newLoc = (Location) delta[0]; if (event instanceof PlayerTeleportEvent) { ((PlayerTeleportEvent) event).setTo(newLoc); } else if (event instanceof EntityTeleportEvent) { ((EntityTeleportEvent) event).setTo(newLoc); } throw new IllegalArgumentException("The event " + event + " should be a PlayerTeleportEvent or EntityTeleportEvent!"); }
@EventHandler(ignoreCancelled = false) public void onTeleport(cn.nukkit.event.entity.EntityTeleportEvent event) { if (canIgnore(EntityTeleportEvent.getHandlerList())) { return; } EntityTeleportEvent bukkitEvent = new EntityTeleportEvent(PokkitEntity.toBukkit(event.getEntity()), PokkitLocation.toBukkit(event.getFrom()), PokkitLocation.toBukkit(event.getTo())); callCancellable(event, bukkitEvent); }
@EventHandler(priority = EventPriority.HIGHEST) public void onBattleTeleport(EntityTeleportEvent event) { if (!Configs.getSettingBoolean("battles.enabled") || Zones.inNoDemigodsZone(event.getEntity().getLocation())) return; if (!Battle.canParticipate(event.getEntity())) return; Participant participant = Battle.defineParticipant(event.getEntity()); if (Battle.isInBattle(participant)) { Battle battle = Battle.getBattle(participant); if (!event.getTo().getWorld().equals(battle.getStartLocation().getWorld()) || DemigodsLocation.distanceFlat(event.getTo(), battle.getStartLocation().getBukkitLocation()) > battle.getRadius()) event.setCancelled(true); } }
private boolean attemptEnderTeleport(EntityHuman entity, final double x, final double y, final double z) { final double prevX = entity.locX; final double prevY = entity.locY; final double prevZ = entity.locZ; entity.locX = x; entity.locY = y; entity.locZ = z; boolean success = false; BlockPosition blockposition = new BlockPosition(entity.locX, entity.locY, entity.locZ); if (entity.world.isLoaded(blockposition)) { boolean foundPos = false; while (!foundPos && (blockposition.getY() > 0)) { final BlockPosition blockposition2 = blockposition.down(); final Block block = entity.world.getType(blockposition2).getBlock(); if (block.getMaterial().isSolid()) { foundPos = true; } else { --entity.locY; blockposition = blockposition2; } } if (foundPos) { final EntityTeleportEvent teleport = new EntityTeleportEvent(entity.getBukkitEntity(), new Location(entity.world.getWorld(), prevX, prevY, prevZ), new Location(entity.world.getWorld(), entity.locX, entity.locY, entity.locZ)); entity.world.getServer().getPluginManager().callEvent(teleport); if (teleport.isCancelled()) { return false; } final Location to = teleport.getTo(); entity.enderTeleportTo(to.getX(), to.getY(), to.getZ()); if (entity.world.getCubes(entity, entity.getBoundingBox()).isEmpty() && !entity.world.containsLiquid(entity.getBoundingBox())) { success = true; } } } if (!success) { entity.setPosition(prevX, prevY, prevZ); return false; } final short count = 128; for (int i = 0; i < count; ++i) { final double d6 = i / (count - 1.0); final float spreadX = (entity.bc().nextFloat() - 0.5f) * 0.2f; final float spreadY = (entity.bc().nextFloat() - 0.5f) * 0.2f; final float spreadZ = (entity.bc().nextFloat() - 0.5f) * 0.2f; final double pX = prevX + ((entity.locX - prevX) * d6) + ((entity.bc().nextDouble() - 0.5) * entity.width * 2.0); final double pY = prevY + ((entity.locY - prevY) * d6) + (entity.bc().nextDouble() * entity.length); final double pZ = prevZ + ((entity.locZ - prevZ) * d6) + ((entity.bc().nextDouble() - 0.5) * entity.width * 2.0); entity.world.addParticle(EnumParticle.PORTAL, pX, pY, pZ, spreadX, spreadY, spreadZ); } entity.world.makeSound(prevX, prevY, prevZ, "mob.endermen.portal", 1.0f, 1.0f); entity.makeSound("mob.endermen.portal", 1.0f, 1.0f); return true; }
public PoreEntityTeleportEvent(org.spongepowered.api.event.entity.EntityTeleportEvent handle) { super(null, null, null); this.handle = checkNotNull(handle, "handle"); }
public org.spongepowered.api.event.entity.EntityTeleportEvent getHandle() { return this.handle; }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) private void onTeleport(EntityTeleportEvent event) { Entity entity = event.getEntity(); if (META.has(entity, TELEPORT_DENY_META_NAME)) event.setCancelled(true); }
public boolean k(double d0, double d1, double d2) { double d3 = this.locX; double d4 = this.locY; double d5 = this.locZ; this.locX = d0; this.locY = d1; this.locZ = d2; boolean flag = false; BlockPosition blockposition = new BlockPosition(this); World world = this.world; Random random = this.getRandom(); if (world.isLoaded(blockposition)) { boolean flag1 = false; while (!flag1 && blockposition.getY() > 0) { BlockPosition blockposition1 = blockposition.down(); IBlockData iblockdata = world.getType(blockposition1); if (iblockdata.getMaterial().isSolid()) { flag1 = true; } else { --this.locY; blockposition = blockposition1; } } if (flag1) { // CraftBukkit start - Teleport event // this.enderTeleportTo(this.locX, this.locY, this.locZ); EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.world.getWorld(), d3, d4, d5), new Location(this.world.getWorld(), this.locX, this.locY, this.locZ)); this.world.getServer().getPluginManager().callEvent(teleport); if (teleport.isCancelled()) { return false; } Location to = teleport.getTo(); this.enderTeleportTo(to.getX(), to.getY(), to.getZ()); // CraftBukkit end if (world.getCubes(this, this.getBoundingBox()).isEmpty() && !world.containsLiquid(this.getBoundingBox())) { flag = true; } } } if (!flag) { this.enderTeleportTo(d3, d4, d5); return false; } else { short short0 = 128; for (int i = 0; i < short0; ++i) { double d6 = (double) i / ((double) short0 - 1.0D); float f = (random.nextFloat() - 0.5F) * 0.2F; float f1 = (random.nextFloat() - 0.5F) * 0.2F; float f2 = (random.nextFloat() - 0.5F) * 0.2F; double d7 = d3 + (this.locX - d3) * d6 + (random.nextDouble() - 0.5D) * (double) this.width * 2.0D; double d8 = d4 + (this.locY - d4) * d6 + random.nextDouble() * (double) this.length; double d9 = d5 + (this.locZ - d5) * d6 + (random.nextDouble() - 0.5D) * (double) this.width * 2.0D; world.addParticle(EnumParticle.PORTAL, d7, d8, d9, (double) f, (double) f1, (double) f2, new int[0]); } if (this instanceof EntityCreature) { ((EntityCreature) this).getNavigation().o(); } return true; } }
@EventHandler (ignoreCancelled = true) public void onEntityTeleport(EntityTeleportEvent event) { Location loc = event.getTo(); if (Util.getQuadtree(loc).contains(loc)) event.setCancelled(true); }
@EventHandler(ignoreCancelled = true) void onEntityTeleport(EntityTeleportEvent event) { if (plugin.isShopkeeper(event.getEntity())) { event.setCancelled(true); } }