@EventHandler(priority = EventPriority.NORMAL) public void onPlayerMove(PlayerMoveEvent event) { final Location from = event.getFrom(); final Location to = event.getTo(); try { if (from.getWorld() == to.getWorld() && from.distanceSquared(to) < (0.0001 * 0.0001)) { // If player just rotated, but didn't move, don't process this event. return; } } catch (IllegalArgumentException ex) { } if (!TFM_AdminWorld.getInstance().validateMovement(event)) { return; } final Player player = event.getPlayer(); final TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player); for (Entry<Player, Double> fuckoff : TotalFreedomMod.fuckoffEnabledFor.entrySet()) { Player fuckoffPlayer = fuckoff.getKey(); if (fuckoffPlayer.equals(player) || !fuckoffPlayer.isOnline()) { continue; } double fuckoffRange = fuckoff.getValue(); Location playerLocation = player.getLocation(); Location fuckoffLocation = fuckoffPlayer.getLocation(); double distanceSquared; try { distanceSquared = playerLocation.distanceSquared(fuckoffLocation); } catch (IllegalArgumentException ex) { continue; } if (distanceSquared < (fuckoffRange * fuckoffRange)) { event.setTo( fuckoffLocation .clone() .add( playerLocation .subtract(fuckoffLocation) .toVector() .normalize() .multiply(fuckoffRange * 1.1))); break; } } // Freeze if (!TFM_AdminList.isSuperAdmin(player) && playerdata.isFrozen()) { TFM_Util.setFlying(player, true); event.setTo(playerdata.getFreezeLocation()); } if (playerdata.isCaged()) { Location targetPos = player.getLocation().add(0, 1, 0); boolean outOfCage; if (!targetPos.getWorld().equals(playerdata.getCagePos().getWorld())) { outOfCage = true; } else { outOfCage = targetPos.distanceSquared(playerdata.getCagePos()) > (2.5 * 2.5); } if (outOfCage) { playerdata.setCaged( true, targetPos, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER), playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER)); playerdata.regenerateHistory(); playerdata.clearHistory(); TFM_Util.buildHistory(targetPos, 2, playerdata); TFM_Util.generateHollowCube( targetPos, 2, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.OUTER)); TFM_Util.generateCube( targetPos, 1, playerdata.getCageMaterial(TFM_PlayerData.CageLayer.INNER)); } } if (playerdata.isOrbiting()) { if (player.getVelocity().length() < playerdata.orbitStrength() * (2.0 / 3.0)) { player.setVelocity(new Vector(0, playerdata.orbitStrength(), 0)); } } if (TFM_Jumppads.getMode().isOn()) { TFM_Jumppads.PlayerMoveEvent(event); } if (!(TFM_ConfigEntry.LANDMINES_ENABLED.getBoolean() && TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())) { return; } final Iterator<Command_landmine.TFM_LandmineData> landmines = Command_landmine.TFM_LandmineData.landmines.iterator(); while (landmines.hasNext()) { final Command_landmine.TFM_LandmineData landmine = landmines.next(); final Location location = landmine.location; if (location.getBlock().getType() != Material.TNT) { landmines.remove(); continue; } if (landmine.player.equals(player)) { break; } if (!player.getWorld().equals(location.getWorld())) { continue; } if (!(player.getLocation().distanceSquared(location) <= (landmine.radius * landmine.radius))) { break; } landmine.location.getBlock().setType(Material.AIR); final TNTPrimed tnt1 = location.getWorld().spawn(location, TNTPrimed.class); tnt1.setFuseTicks(40); tnt1.setPassenger(player); tnt1.setVelocity(new Vector(0.0, 2.0, 0.0)); final TNTPrimed tnt2 = location.getWorld().spawn(player.getLocation(), TNTPrimed.class); tnt2.setFuseTicks(1); player.setGameMode(GameMode.SURVIVAL); landmines.remove(); } }
@Override public boolean run( CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) { if (args.length == 0) { return false; } if (TFM_Util.isStopCommand(args[0]) && sender instanceof Player) { TFM_Util.adminAction(sender.getName(), "Uncaging " + sender.getName(), true); TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(sender_p); playerdata.setCaged(false); playerdata.regenerateHistory(); playerdata.clearHistory(); return true; } else if ("purge".equalsIgnoreCase(args[0])) { TFM_Util.adminAction(sender.getName(), "Uncaging all players.", true); for (Player player : server.getOnlinePlayers()) { TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player); playerdata.setCaged(false); playerdata.regenerateHistory(); playerdata.clearHistory(); } return true; } Player player; try { player = getPlayer(args[0]); } catch (PlayerNotFoundException ex) { sender.sendMessage(ex.getMessage()); return true; } TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(player); Material outerMaterial = Material.GLASS; Material innerMaterial = Material.AIR; if (args.length >= 2) { if (TFM_Util.isStopCommand(args[1])) { TFM_Util.adminAction(sender.getName(), "Uncaging " + player.getName(), true); playerdata.setCaged(false); playerdata.regenerateHistory(); playerdata.clearHistory(); return true; } else { if ("bloop".equalsIgnoreCase(args[1])) { outerMaterial = Material.SKULL; } else if (Material.matchMaterial(args[1]) != null) { outerMaterial = Material.matchMaterial(args[1]); } } } if (args.length >= 3) { if (args[2].equalsIgnoreCase("water")) { innerMaterial = Material.STATIONARY_WATER; } else if (args[2].equalsIgnoreCase("lava")) { innerMaterial = Material.STATIONARY_LAVA; } } Location targetPos = player.getLocation().clone().add(0, 1, 0); playerdata.setCaged(true, targetPos, outerMaterial, innerMaterial); playerdata.regenerateHistory(); playerdata.clearHistory(); TFM_Util.buildHistory(targetPos, 2, playerdata); TFM_Util.generateHollowCube(targetPos, 2, outerMaterial); TFM_Util.generateCube(targetPos, 1, innerMaterial); player.setGameMode(GameMode.SURVIVAL); if (outerMaterial != Material.SKULL) { TFM_Util.adminAction(sender.getName(), "Caging " + player.getName(), true); } else { TFM_Util.adminAction( sender.getName(), "Caging " + player.getName() + " in PURE_BLOOPEH", true); } return true; }