Don't nag players with mobarena.admin.teleport.
Changes the behavior of the ArenaListener's teleport event handler such
that it _ignores_ teleport attempts instead of _rejecting_ them when the
player in question has the `mobarena.admin.teleport` permission. Because
the global listener's event handler only ever checks the permission if
at least one per-arena listener has _rejected_ the teleport attempt, and
none of them have explicitly _allowed_ it, the change means that it will
never check the permission, because its internal `allow` flag will never
change to `false`. Thus, the check can be safely removed from the global
listener's logic.
When the response is to ignore instead of reject, the message that would
have otherwise been sent to the player is skipped. This fixes #702.
It is perhaps tempting to move the permission check up into the section
of sanity checks in the global listener, but this is very specifically
avoided to allow MobArena to _uncancel_ teleport events that have been
cancelled by other plugins, but that MobArena might need to go through.
Please see afcc526a71 for more info.
This commit is contained in:
@@ -1291,23 +1291,20 @@ public class ArenaListener
|
||||
if (region.contains(to)) {
|
||||
// Inside -> inside
|
||||
if (!(arena.inArena(p) || arena.inLobby(p))) {
|
||||
arena.getMessenger().tell(p, Msg.WARP_TO_ARENA);
|
||||
return TeleportResponse.REJECT;
|
||||
return reject(p, Msg.WARP_TO_ARENA);
|
||||
}
|
||||
return TeleportResponse.ALLOW;
|
||||
} else {
|
||||
// Inside -> outside
|
||||
if (arena.getAllPlayers().contains(p)) {
|
||||
arena.getMessenger().tell(p, Msg.WARP_FROM_ARENA);
|
||||
return TeleportResponse.REJECT;
|
||||
return reject(p, Msg.WARP_FROM_ARENA);
|
||||
}
|
||||
return TeleportResponse.IDGAF;
|
||||
}
|
||||
} else {
|
||||
if (region.contains(to)) {
|
||||
// Outside -> inside
|
||||
arena.getMessenger().tell(p, Msg.WARP_TO_ARENA);
|
||||
return TeleportResponse.REJECT;
|
||||
return reject(p, Msg.WARP_TO_ARENA);
|
||||
} else {
|
||||
// Outside -> outside
|
||||
return TeleportResponse.IDGAF;
|
||||
@@ -1315,6 +1312,15 @@ public class ArenaListener
|
||||
}
|
||||
}
|
||||
|
||||
private TeleportResponse reject(Player p, Msg message) {
|
||||
if (p.hasPermission("mobarena.admin.teleport")) {
|
||||
return TeleportResponse.IDGAF;
|
||||
}
|
||||
|
||||
arena.getMessenger().tell(p, message);
|
||||
return TeleportResponse.REJECT;
|
||||
}
|
||||
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
Player p = event.getPlayer();
|
||||
|
||||
|
||||
@@ -369,10 +369,9 @@ public class MAGlobalListener implements Listener
|
||||
/*
|
||||
* 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.
|
||||
* may have to cancel the event.
|
||||
*/
|
||||
if (!allow && !event.getPlayer().hasPermission("mobarena.admin.teleport")) {
|
||||
if (!allow) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user