diff --git a/changelog.md b/changelog.md index f197149..af6bf43 100644 --- a/changelog.md +++ b/changelog.md @@ -13,6 +13,10 @@ These changes will (most likely) be included in the next version. ## [Unreleased] - MobArena no longer touches the `flySpeed` player attribute when players join an arena. This should fix issues where a crash would result in players being "locked in the air" when trying to fly outside of the arena. It also introduces compatibility with plugins that use flight to augment player abilities. - Fixed a bug introduced by a breaking API change in Spigot where a player with a nearly full inventory might cause item rewards to change stack amounts. +- MobArena no longer uncancels teleport events that occur outside of its own context when players have the `mobarena.admin.teleport` permission. This fixes a bug where the permission could override the cancellation of events that weren't related to MobArena. + +Thanks to: +- minoneer for help with fixing and testing the teleport bug ## [0.103.1] - 2018-12-31 - Like the other user commands, the permission for `/ma ready` now defaults to true. diff --git a/src/main/java/com/garbagemule/MobArena/ArenaListener.java b/src/main/java/com/garbagemule/MobArena/ArenaListener.java index e31af88..deb8e51 100644 --- a/src/main/java/com/garbagemule/MobArena/ArenaListener.java +++ b/src/main/java/com/garbagemule/MobArena/ArenaListener.java @@ -1214,7 +1214,7 @@ public class ArenaListener * transition and are removed from that state as soon as the transition * is complete. */ - if (arena.isMoving(p) || p.hasPermission("mobarena.admin.teleport")) { + if (arena.isMoving(p)) { return TeleportResponse.ALLOW; } diff --git a/src/main/java/com/garbagemule/MobArena/listeners/MAGlobalListener.java b/src/main/java/com/garbagemule/MobArena/listeners/MAGlobalListener.java index 3de8e30..5eec8bb 100644 --- a/src/main/java/com/garbagemule/MobArena/listeners/MAGlobalListener.java +++ b/src/main/java/com/garbagemule/MobArena/listeners/MAGlobalListener.java @@ -348,7 +348,7 @@ public class MAGlobalListener implements Listener @EventHandler(priority = EventPriority.NORMAL) public void playerTeleport(PlayerTeleportEvent event) { if (!am.isEnabled()) return; - + boolean allow = true; for (Arena arena : am.getArenas()) { TeleportResponse r = arena.getEventListener().onPlayerTeleport(event); @@ -364,9 +364,14 @@ public class MAGlobalListener implements Listener default: break; } } - - // Only cancel if at least one arena has rejected the teleport. - if (!allow) { + + /* + * If we reach this point, no arena has specifically allowed the + * teleport, but one or more arenas may have rejected it, so we + * may have to cancel the event. If the player has the teleport + * override permission, however, we don't cancel. + */ + if (!allow && !event.getPlayer().hasPermission("mobarena.admin.teleport")) { event.setCancelled(true); } }