mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-22 10:36:00 +01:00
Relocate mobarena.admin.teleport
permission check.
Instead of explicitly ALLOW'ing a teleport if a player has the permission, we let the teleport handler logic run its course. If an arena explicitly REJECTs the teleport, we need to cancel the event, but the permission now overrides that behavior. This means that only in the case of an impending event cancellation, the permission kicks in. This is important, because the permission is supposed to override the decision to cancel, rather than drive the decision to uncancel. With this change, MobArena never uncancels something it wouldn't have uncancelled otherwise, meaning it won't interfere with teleports outside of its own context, and thus won't interfere with other plugins. Fixes #515, closes #516 Thanks to @minoneer for the bug report and pull request that this code was based upon!
This commit is contained in:
parent
fc8debca29
commit
afcc526a71
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user