From 382f4c4b0c76fb4e139992d0971ee5286cbc472c Mon Sep 17 00:00:00 2001 From: Trent Hensler Date: Tue, 20 Mar 2018 19:24:21 -0700 Subject: [PATCH] Check fly on teleport. Fixes #1099 --- .../factions/listeners/FactionsPlayerListener.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 0c0a757d..d60e76dd 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -9,10 +9,10 @@ import com.massivecraft.factions.scoreboards.sidebar.FDefaultSidebar; import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Role; +import com.massivecraft.factions.util.FactionGUI; import com.massivecraft.factions.util.VisualizeUtil; import com.massivecraft.factions.zcore.fperms.Access; import com.massivecraft.factions.zcore.fperms.PermissableAction; -import com.massivecraft.factions.util.FactionGUI; import com.massivecraft.factions.zcore.persist.MemoryFPlayer; import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TextUtil; @@ -519,6 +519,18 @@ public class FactionsPlayerListener implements Listener { } } + @EventHandler + public void onTeleport(PlayerTeleportEvent event) { + FPlayer me = FPlayers.getInstance().getByPlayer(event.getPlayer()); + FLocation to = new FLocation(event.getTo()); + + // Check the location they're teleporting to and check if they can fly there. + if (!me.isAdminBypassing() && me.isFlying() && !me.canFlyAtLocation(to)) { + me.setFFlying(false, false); + } + + } + // For some reason onPlayerInteract() sometimes misses bucket events depending on distance (something like 2-3 blocks away isn't detected), // but these separate bucket events below always fire without fail @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)