Skip to content

Commit

Permalink
Fix other types of teleports bypassing flight test. (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
LlmDl authored Mar 2, 2024
1 parent bc5d8a1 commit cd9f212
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.llmdlio</groupId>
<artifactId>TownyFlight</artifactId>
<version>1.10.0</version>
<version>1.10.1</version>
<name>TownyFlight</name>
<description>A flight plugin for Towny servers.</description>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down

0 comments on commit cd9f212

Please sign in to comment.