From 545d706a7005f879236318f27c89eb855feed02f Mon Sep 17 00:00:00 2001 From: KHobbits Date: Mon, 3 Mar 2014 21:24:00 +0000 Subject: [PATCH] Fix login death caused by built up fall damage using /fly. --- .../essentials/EssentialsPlayerListener.java | 107 +++++++++--------- 1 file changed, 54 insertions(+), 53 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java index 975559026..2f7128d39 100644 --- a/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/EssentialsPlayerListener.java @@ -37,25 +37,25 @@ public class EssentialsPlayerListener implements Listener { private static final Logger LOGGER = Logger.getLogger("Essentials"); private final transient IEssentials ess; - + public EssentialsPlayerListener(final IEssentials parent) { this.ess = parent; } - + @EventHandler(priority = EventPriority.NORMAL) public void onPlayerRespawn(final PlayerRespawnEvent event) { final User user = ess.getUser(event.getPlayer()); updateCompass(user); user.setDisplayNick(); - + if (ess.getSettings().isTeleportInvulnerability()) { user.enableInvulnerabilityAfterTeleport(); } } - + @EventHandler(priority = EventPriority.LOWEST) public void onPlayerChat(final AsyncPlayerChatEvent event) { @@ -89,11 +89,11 @@ public class EssentialsPlayerListener implements Listener ess.getLogger().info("Ignore could not block chat due to custom chat plugin event."); } } - + user.updateActivity(true); user.setDisplayNick(); } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerMove(final PlayerMoveEvent event) { @@ -103,19 +103,19 @@ public class EssentialsPlayerListener implements Listener { return; } - + if (!ess.getSettings().cancelAfkOnMove() && !ess.getSettings().getFreezeAfkPlayers()) { event.getHandlers().unregister(this); - + if (ess.getSettings().isDebug()) { LOGGER.log(Level.INFO, "Unregistering move listener"); } - + return; } - + final User user = ess.getUser(event.getPlayer()); if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers()) { @@ -146,12 +146,12 @@ public class EssentialsPlayerListener implements Listener user.updateActivity(true); } } - + @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerQuit(final PlayerQuitEvent event) { final User user = ess.getUser(event.getPlayer()); - + if (ess.getSettings().allowSilentJoinQuit() && user.isAuthorized("essentials.silentquit")) { event.setQuitMessage(null); @@ -164,7 +164,7 @@ public class EssentialsPlayerListener implements Listener .replace("{PLAYER}", player.getDisplayName()) .replace("{USERNAME}", player.getName())); } - + if (ess.getSettings().removeGodOnDisconnect() && user.isGodModeEnabled()) { user.setGodModeEnabled(false); @@ -181,7 +181,7 @@ public class EssentialsPlayerListener implements Listener user.updateActivity(false); user.dispose(); } - + @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerJoin(final PlayerJoinEvent event) { @@ -199,27 +199,27 @@ public class EssentialsPlayerListener implements Listener event.setJoinMessage(null); } } - + public void delayedJoin(final Player player, final String message) { if (!player.isOnline()) { return; } - + ess.getBackup().onPlayerJoin(); final User user = ess.getUser(player); - - + + if (user.isNPC()) { user.setNPC(false); } - + final long currentTime = System.currentTimeMillis(); user.checkMuteTimeout(currentTime); user.updateActivity(false); - + ess.scheduleSyncDelayedTask(new Runnable() { @Override @@ -229,12 +229,12 @@ public class EssentialsPlayerListener implements Listener { return; } - + user.trackUUID(); user.setLastLogin(currentTime); user.setDisplayNick(); updateCompass(user); - + if (!ess.getVanishedPlayers().isEmpty() && !user.isAuthorized("essentials.vanish.see")) { for (String p : ess.getVanishedPlayers()) @@ -246,12 +246,12 @@ public class EssentialsPlayerListener implements Listener } } } - + if (user.isAuthorized("essentials.sleepingignored")) { user.setSleepingIgnored(true); } - + if ((ess.getSettings().allowSilentJoinQuit() && user.isAuthorized("essentials.silentjoin")) || message == null) { // Do nothing - silently join @@ -267,7 +267,7 @@ public class EssentialsPlayerListener implements Listener { ess.getServer().broadcastMessage(message); } - + if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd")) { try @@ -289,7 +289,7 @@ public class EssentialsPlayerListener implements Listener } } } - + if (!ess.getSettings().isCommandDisabled("mail") && user.isAuthorized("essentials.mail")) { final List mail = user.getMails(); @@ -302,19 +302,20 @@ public class EssentialsPlayerListener implements Listener user.sendMessage(_("youHaveNewMail", mail.size())); } } - + if (user.isAuthorized("essentials.fly.safelogin")) { + user.setFallDistance(0); if (LocationUtil.shouldFly(user.getLocation())) { user.setAllowFlight(true); user.setFlying(true); user.sendMessage(_("flyMode", _("enabled"), user.getDisplayName())); - } + } } user.setFlySpeed(0.1f); user.setWalkSpeed(0.2f); - + } }); } @@ -333,7 +334,7 @@ public class EssentialsPlayerListener implements Listener user.setCompassTarget(updateLoc); } } - + @EventHandler(priority = EventPriority.LOWEST) public void onPlayerLogin2(final PlayerLoginEvent event) { @@ -344,11 +345,11 @@ public class EssentialsPlayerListener implements Listener default: return; } - + final String banReason = _("banFormat", _("defaultBanReason"), "Console"); event.disallow(Result.KICK_BANNED, banReason); } - + @EventHandler(priority = EventPriority.HIGH) public void onPlayerLogin(final PlayerLoginEvent event) { @@ -360,9 +361,9 @@ public class EssentialsPlayerListener implements Listener default: return; } - + final User user = ess.getUser(event.getPlayer()); - + if (event.getResult() == Result.KICK_BANNED || user.isBanned()) { final boolean banExpired = user.checkBanTimeout(System.currentTimeMillis()); @@ -382,7 +383,7 @@ public class EssentialsPlayerListener implements Listener return; } } - + if (event.getResult() == Result.KICK_FULL && !user.isAuthorized("essentials.joinfullserver")) { event.disallow(Result.KICK_FULL, _("serverFull")); @@ -390,7 +391,7 @@ public class EssentialsPlayerListener implements Listener } event.allow(); } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerTeleport(final PlayerTeleportEvent event) { @@ -410,7 +411,7 @@ public class EssentialsPlayerListener implements Listener } } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerEggThrow(final PlayerEggThrowEvent event) { @@ -422,7 +423,7 @@ public class EssentialsPlayerListener implements Listener user.updateInventory(); } } - + @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event) { @@ -440,7 +441,7 @@ public class EssentialsPlayerListener implements Listener }); } } - + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event) { @@ -463,7 +464,7 @@ public class EssentialsPlayerListener implements Listener user.updateActivity(true); } } - + @EventHandler(priority = EventPriority.NORMAL) public void onPlayerChangedWorldFlyReset(final PlayerChangedWorldEvent event) { @@ -488,7 +489,7 @@ public class EssentialsPlayerListener implements Listener { user.setFlySpeed(user.getFlySpeed() * 0.99999f); } - + if (user.getWalkSpeed() > ess.getSettings().getMaxWalkSpeed() && !user.isAuthorized("essentials.speed.bypass")) { user.setWalkSpeed((float)ess.getSettings().getMaxWalkSpeed()); @@ -499,7 +500,7 @@ public class EssentialsPlayerListener implements Listener } } } - + @EventHandler(priority = EventPriority.MONITOR) public void onPlayerChangedWorld(final PlayerChangedWorldEvent event) { @@ -511,7 +512,7 @@ public class EssentialsPlayerListener implements Listener { user.sendMessage(_("noGodWorldWarning")); } - + if (!user.getWorld().getName().equals(newWorld)) { user.sendMessage(_("currentWorld", newWorld)); @@ -521,7 +522,7 @@ public class EssentialsPlayerListener implements Listener user.setVanished(user.isAuthorized("essentials.vanish")); } } - + @EventHandler(priority = EventPriority.NORMAL) public void onPlayerInteract(final PlayerInteractEvent event) { @@ -570,7 +571,7 @@ public class EssentialsPlayerListener implements Listener try { final Location otarget = LocationUtil.getTarget(user.getBase()); - + ess.scheduleSyncDelayedTask( new Runnable() { @@ -596,7 +597,7 @@ public class EssentialsPlayerListener implements Listener } } } - + private boolean usePowertools(final User user, final int id) { final List commandList = user.getPowertool(id); @@ -634,7 +635,7 @@ public class EssentialsPlayerListener implements Listener } return used; } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerPickupItem(final PlayerPickupItemEvent event) { @@ -646,14 +647,14 @@ public class EssentialsPlayerListener implements Listener } } } - + @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onInventoryClickEvent(final InventoryClickEvent event) { Player refreshPlayer = null; final Inventory top = event.getView().getTopInventory(); final InventoryType type = top.getType(); - + if (type == InventoryType.PLAYER) { final User user = ess.getUser((Player)event.getWhoClicked()); @@ -698,7 +699,7 @@ public class EssentialsPlayerListener implements Listener refreshPlayer = user.getBase(); } } - + if (refreshPlayer != null) { final Player player = refreshPlayer; @@ -712,7 +713,7 @@ public class EssentialsPlayerListener implements Listener }, 1); } } - + @EventHandler(priority = EventPriority.MONITOR) public void onInventoryCloseEvent(final InventoryCloseEvent event) { @@ -751,7 +752,7 @@ public class EssentialsPlayerListener implements Listener refreshPlayer = user.getBase(); } } - + if (refreshPlayer != null) { final Player player = refreshPlayer; @@ -765,7 +766,7 @@ public class EssentialsPlayerListener implements Listener }, 1); } } - + @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onPlayerFishEvent(final PlayerFishEvent event) {