From cd9f2122c95c1adb3052f9b90c2605b371cb5d40 Mon Sep 17 00:00:00 2001 From: LlmDl Date: Sat, 2 Mar 2024 17:08:56 -0600 Subject: [PATCH] Fix other types of teleports bypassing flight test. (#76) --- pom.xml | 2 +- .../townyflight/listeners/PlayerTeleportListener.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 6760898..4def3df 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.gmail.llmdlio TownyFlight - 1.10.0 + 1.10.1 TownyFlight A flight plugin for Towny servers. diff --git a/src/main/java/com/gmail/llmdlio/townyflight/listeners/PlayerTeleportListener.java b/src/main/java/com/gmail/llmdlio/townyflight/listeners/PlayerTeleportListener.java index badd35f..40b4206 100644 --- a/src/main/java/com/gmail/llmdlio/townyflight/listeners/PlayerTeleportListener.java +++ b/src/main/java/com/gmail/llmdlio/townyflight/listeners/PlayerTeleportListener.java @@ -16,7 +16,7 @@ public class PlayerTeleportListener implements Listener { @EventHandler(priority = EventPriority.MONITOR) private void playerTeleports(PlayerTeleportEvent event) { - if (event.getCause() != TeleportCause.PLUGIN || event.getCause() != TeleportCause.COMMAND) + if (!aTeleportCauseThatMatters(event.getCause())) return; Player player = event.getPlayer(); @@ -29,6 +29,11 @@ private void playerTeleports(PlayerTeleportEvent event) { TownyFlightAPI.getInstance().removeFlight(player, false, true, ""); } + private boolean aTeleportCauseThatMatters(TeleportCause teleportCause) { + return teleportCause == TeleportCause.PLUGIN || teleportCause == TeleportCause.COMMAND || + teleportCause == TeleportCause.ENDER_PEARL || teleportCause == TeleportCause.CHORUS_FRUIT; + } + private boolean flightAllowedDestination(Player player, Location loc) { Resident resident = TownyUniverse.getInstance().getResident(player.getUniqueId()); return resident != null && TownyFlightAPI.allowedLocation(player, loc, resident);