@EventHandler(priority = EventPriority.NORMAL) public void onPlayerMove(PlayerMoveEvent event) { if (!TFM_AdminWorld.getInstance().validateMovement(event)) { return; } Player p = event.getPlayer(); TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(p); for (Entry<Player, Double> fuckoff : TotalFreedomMod.fuckoffEnabledFor.entrySet()) { Player fuckoff_player = fuckoff.getKey(); if (fuckoff_player.equals(p) || !fuckoff_player.isOnline()) { continue; } double fuckoff_range = fuckoff.getValue().doubleValue(); Location mover_pos = p.getLocation(); Location fuckoff_pos = fuckoff_player.getLocation(); double distanceSquared; try { distanceSquared = mover_pos.distanceSquared(fuckoff_pos); } catch (IllegalArgumentException ex) { continue; } if (distanceSquared < (fuckoff_range * fuckoff_range)) { event.setTo( fuckoff_pos .clone() .add( mover_pos .subtract(fuckoff_pos) .toVector() .normalize() .multiply(fuckoff_range * 1.1))); break; } } boolean do_freeze = false; if (TotalFreedomMod.allPlayersFrozen) { if (!TFM_SuperadminList.isUserSuperadmin(p)) { do_freeze = true; } } else { if (playerdata.isFrozen()) { do_freeze = true; } } if (do_freeze) { Location from = event.getFrom(); Location to = event.getTo().clone(); to.setX(from.getX()); to.setY(from.getY()); to.setZ(from.getZ()); event.setTo(to); } if (playerdata.isCaged()) { Location target_pos = p.getLocation().add(0, 1, 0); boolean out_of_cage; if (!target_pos.getWorld().equals(playerdata.getCagePos().getWorld())) { out_of_cage = true; } else { out_of_cage = target_pos.distanceSquared(playerdata.getCagePos()) > (2.5 * 2.5); } if (out_of_cage) { playerdata.setCaged( true, target_pos, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER), playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER)); playerdata.regenerateHistory(); playerdata.clearHistory(); TFM_Util.buildHistory(target_pos, 2, playerdata); TFM_Util.generateCube( target_pos, 2, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER)); TFM_Util.generateCube( target_pos, 1, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER)); } } if (playerdata.isOrbiting()) { if (p.getVelocity().length() < playerdata.orbitStrength() * (2.0 / 3.0)) { p.setVelocity(new Vector(0, playerdata.orbitStrength(), 0)); } } if (TotalFreedomMod.landminesEnabled && TotalFreedomMod.allowExplosions) { Iterator<TFM_LandmineData> landmines = TFM_LandmineData.landmines.iterator(); while (landmines.hasNext()) { TFM_LandmineData landmine = landmines.next(); Location landmine_pos = landmine.landmine_pos; if (landmine_pos.getBlock().getType() != Material.TNT) { landmines.remove(); continue; } if (!landmine.player.equals(p)) { if (p.getWorld().equals(landmine_pos.getWorld())) { if (p.getLocation().distanceSquared(landmine_pos) <= (landmine.radius * landmine.radius)) { landmine.landmine_pos.getBlock().setType(Material.AIR); TNTPrimed tnt1 = landmine_pos.getWorld().spawn(landmine_pos, TNTPrimed.class); tnt1.setFuseTicks(40); tnt1.setPassenger(p); tnt1.setVelocity(new Vector(0.0, 2.0, 0.0)); TNTPrimed tnt2 = landmine_pos.getWorld().spawn(p.getLocation(), TNTPrimed.class); tnt2.setFuseTicks(1); p.setGameMode(GameMode.SURVIVAL); landmines.remove(); } } } } } }
@EventHandler(priority = EventPriority.HIGHEST) public void onPlayerTeleport(PlayerTeleportEvent event) { TFM_AdminWorld.getInstance().validateMovement(event); }