@EventHandler public void onPlayerMove(PlayerMoveEvent e) { Player p = e.getPlayer(); Location loc = new Location( e.getTo().getWorld(), (int) e.getTo().getX(), (int) e.getTo().getY(), (int) e.getTo().getZ()); if (Main.getInstance().redSpawnArea.contains(loc)) { Bukkit.getPluginManager().callEvent(new AreaWalkEvent(Area.RED_SPAWN, p)); } if (Main.getInstance().blueSpawnArea.contains(loc)) { Bukkit.getPluginManager().callEvent(new AreaWalkEvent(Area.BLUE_SPAWN, p)); } if (Main.getInstance().blockspawnAreas.contains(loc)) { Bukkit.getPluginManager().callEvent(new AreaWalkEvent(getArea(loc), p)); } if (blockManager.canPickUpBlock(p)) { blockManager.pickUpBlock(p); } if (canGetNeededBlock(p)) { if (p.getGameMode() == GameMode.SURVIVAL) { gameManager.setCarrying(p, nexusManager.getCurrentNexusColor()); String[] data = neededBlockMaterial.split(";"); neededBlock .getBlock() .setTypeIdAndData(Integer.valueOf(data[0]), Byte.valueOf(data[1]), false); neededBlock = new Location(Bukkit.getWorlds().get(0), 0, 0, 0); Bukkit.broadcastMessage( Color.np( "&6The needed block was picked up by the " + teamManager.getTeam(p).getTeamName() + "&6 team!")); } } if ((int) e.getFrom().getX() != (int) e.getTo().getX() || (int) e.getFrom().getZ() != (int) e.getTo().getZ() || (int) e.getFrom().getY() != (int) e.getTo().getY()) { if (getTurret(loc) != null) { Bukkit.getPluginManager().callEvent(new TurretWalkEvent(p, getTurret(loc))); } if (isInTurret(p)) { Turret t = getTurret(p); if (t.containsUser()) { e.getPlayer().teleport(e.getFrom()); } } } if ((int) e.getFrom().getX() != (int) e.getTo().getX() || (int) e.getFrom().getZ() != (int) e.getTo().getZ()) { if (!released || stunned.contains(p.getName())) { if (GameState.getState() == GameState.INGAME) { e.getPlayer().teleport(e.getFrom()); } } } }
@EventHandler(priority = EventPriority.HIGH) public void onPlayerMove(PlayerMoveEvent event) { if (event.isCancelled()) return; if (AFKUtils.isAfk(event.getPlayer())) { AFKUtils.unsetAfk(event.getPlayer()); plugin.getServer().broadcastMessage(event.getPlayer().getName() + " is no longer AFK."); return; } if (PConfManager.getPValBoolean(event.getPlayer(), "frozen")) event.setCancelled(true); }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerMove(final PlayerMoveEvent event) { final IUser user = userMap.getUser(event.getPlayer()); final ISettings settings = ess.getSettings(); if (user.getData().isAfk() && settings.getData().getCommands().getAfk().isFreezeAFKPlayers()) { final Location from = event.getFrom(); final Location to = event.getTo().clone(); to.setX(from.getX()); to.setY(from.getY()); to.setZ(from.getZ()); try { event.setTo(LocationUtil.getSafeDestination(to)); } catch (Exception ex) { event.setTo(to); } return; } final Location afk = user.getAfkPosition(); if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9) { user.updateActivity(true); } }
@EventHandler public void onMove(PlayerMoveEvent event) { if (ConfigUtil.get().getConfig().getBoolean("tp-to-spawn")) { if (event.getTo().getY() <= 0) { Location teleportTo = LocationUtil.get() .deserialize(ConfigUtil.get().getConfig().getString("spawn.location")); event.getPlayer().teleport(teleportTo); } } }
@EventHandler public void onPlayerMove(PlayerMoveEvent event) { String playerName = event.getPlayer().getName(); if (!moveCooldown.isOnCooldown(playerName)) { GamePlayer gamePlayer = FakeboardHandler.getPlayer(playerName); if (GameSetupHandler.isGameInProgress()) { // TODO prevent the null check from being needed if (gamePlayer != null && gamePlayer.isAfk()) { gamePlayer.setAfk(false, false); } } moveCooldown.setOnCooldown(playerName); } }
@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.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; } Player player = event.getPlayer(); 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().doubleValue(); 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; } } boolean freeze = false; if (TotalFreedomMod.allPlayersFrozen) { if (!TFM_AdminList.isSuperAdmin(player)) { freeze = true; } } else { if (playerdata.isFrozen()) { freeze = true; } } if (freeze) { Location freezeTo = to.clone(); freezeTo.setX(from.getX()); freezeTo.setY(from.getY()); freezeTo.setZ(from.getZ()); event.setTo(freezeTo); } 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.getInstance().getMode().isOn()) { TFM_Jumppads.getInstance().PlayerMoveEvent(event); } if (!(TFM_ConfigEntry.LANDMINES_ENABLED.getBoolean() && TFM_ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())) { return; } Iterator<Command_landmine.TFM_LandmineData> landmines = Command_landmine.TFM_LandmineData.landmines.iterator(); while (landmines.hasNext()) { Command_landmine.TFM_LandmineData landmine = landmines.next(); 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())) { break; } if (!(player.getLocation().distanceSquared(location) <= (landmine.radius * landmine.radius))) { break; } landmine.location.getBlock().setType(Material.AIR); TNTPrimed tnt1 = location.getWorld().spawn(location, TNTPrimed.class); tnt1.setFuseTicks(40); tnt1.setPassenger(player); tnt1.setVelocity(new Vector(0.0, 2.0, 0.0)); TNTPrimed tnt2 = location.getWorld().spawn(player.getLocation(), TNTPrimed.class); tnt2.setFuseTicks(1); player.setGameMode(GameMode.SURVIVAL); landmines.remove(); } }
public void onPlayerChat(PlayerMoveEvent event) { Player player = event.getPlayer(); String playerName = player.getName(); plugin.users.put(playerName, System.currentTimeMillis()); }
@EventHandler public void afk(PlayerMoveEvent e) { AFKUtils.setLastMove(e.getPlayer(), new Date().getTime()); }