@Override public void setTo(MCLocation newloc) { World w = ((BukkitMCWorld) newloc.getWorld()).__World(); Location loc = new Location( w, newloc.getX(), newloc.getY(), newloc.getZ(), newloc.getPitch(), newloc.getYaw() ); e.setTo(loc); }
@EventHandler public void onTeleport(PlayerTeleportEvent event) { Location loc = event.getTo(); if (event.isCancelled()) { return; } // Work around someone's bug if (loc == null || loc.getWorld() == null) { return; } if (loc.equals(loc.getWorld().getSpawnLocation())) { event.setTo(getSpawnPoint(loc.getWorld())); } }
@EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) public void enderPearlTeleport(PlayerTeleportEvent event) { if (!Conf.handleExploitEnderPearlClipping) { return; } if (event.getCause() != PlayerTeleportEvent.TeleportCause.ENDER_PEARL) { return; } // this exploit works when the target location is within 0.31 blocks or so of a door or glass block or similar... Location target = event.getTo(); Location from = event.getFrom(); // blocks who occupy less than 1 block width or length wise need to be handled differently Material mat = event.getTo().getBlock().getType(); if (((mat == SavageFactions.plugin.THIN_GLASS || mat == SavageFactions.plugin.IRON_FENCE) && clippingThrough(target, from, 0.65)) || ((mat == SavageFactions.plugin.FENCE || mat == SavageFactions.plugin.NETHER_FENCE) && clippingThrough(target, from, 0.45))) { event.setTo(from); return; } // simple fix otherwise: ender pearl target locations are standardized to be in the center (X/Z) of the target block, not at the edges target.setX(target.getBlockX() + 0.5); target.setZ(target.getBlockZ() + 0.5); event.setTo(target); } }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onPlayerTeleport(PlayerTeleportEvent event) { // if knockback is set to 0, simply return if (Config.KnockBack() == 0.0) return; if (Config.Debug()) Config.log("Teleport cause: " + event.getCause().toString()); Location newLoc = BorderCheckTask.checkPlayer(event.getPlayer(), event.getTo(), true, true); if (newLoc != null) { if(event.getCause() == PlayerTeleportEvent.TeleportCause.ENDER_PEARL && Config.getDenyEnderpearl()) { event.setCancelled(true); return; } event.setTo(newLoc); } }
private final void undoCancelledSetBack(final Player player, final PlayerTeleportEvent event, final MovingData data, final IPlayerData pData) { // Prevent cheaters getting rid of flying data (morepackets, other). // TODO: even more strict enforcing ? event.setCancelled(false); // TODO: Does this make sense? Have it configurable rather? if (!data.isTeleported(event.getTo())) { final Location teleported = data.getTeleported(); event.setTo(teleported); /* * Setting from ... not sure this is relevant. Idea was to avoid * subtleties with other plugins, but it probably can't be * estimated, if this means more or less 'subtleties' in the end * (amortized). */ event.setFrom(teleported); } if (pData.isDebugActive(checkType)) { NCPAPIProvider.getNoCheatPlusAPI().getLogManager().warning( Streams.TRACE_FILE, player.getName() + " TP " + event.getCause() + " (revert cancel on set back): " + event.getTo()); } }
if (newTo != null) { event.setTo(newTo);
event.setTo(loc); plugin.getCommunicationManager().warnEntry(player, field); return;