mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-23 02:55:46 +01:00
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:
parent
77b2525707
commit
d4dcc8dc90
@ -37,6 +37,7 @@ These changes will (most likely) be included in the next version.
|
|||||||
- Flaming arrows now ignite TNT blocks in the arena.
|
- Flaming arrows now ignite TNT blocks in the arena.
|
||||||
- Players no longer take fall damage when they leave (or get removed from) an arena while falling.
|
- Players no longer take fall damage when they leave (or get removed from) an arena while falling.
|
||||||
- Players no longer take damage from projectiles shot by pets of other players.
|
- Players no longer take damage from projectiles shot by pets of other players.
|
||||||
|
- MobArena no longer nags players with the `mobarena.admin.teleport` permission when they engage in a teleport that would have otherwise been blocked.
|
||||||
|
|
||||||
## [0.106] - 2021-05-09
|
## [0.106] - 2021-05-09
|
||||||
### Added
|
### Added
|
||||||
|
@ -1291,23 +1291,20 @@ public class ArenaListener
|
|||||||
if (region.contains(to)) {
|
if (region.contains(to)) {
|
||||||
// Inside -> inside
|
// Inside -> inside
|
||||||
if (!(arena.inArena(p) || arena.inLobby(p))) {
|
if (!(arena.inArena(p) || arena.inLobby(p))) {
|
||||||
arena.getMessenger().tell(p, Msg.WARP_TO_ARENA);
|
return reject(p, Msg.WARP_TO_ARENA);
|
||||||
return TeleportResponse.REJECT;
|
|
||||||
}
|
}
|
||||||
return TeleportResponse.ALLOW;
|
return TeleportResponse.ALLOW;
|
||||||
} else {
|
} else {
|
||||||
// Inside -> outside
|
// Inside -> outside
|
||||||
if (arena.getAllPlayers().contains(p)) {
|
if (arena.getAllPlayers().contains(p)) {
|
||||||
arena.getMessenger().tell(p, Msg.WARP_FROM_ARENA);
|
return reject(p, Msg.WARP_FROM_ARENA);
|
||||||
return TeleportResponse.REJECT;
|
|
||||||
}
|
}
|
||||||
return TeleportResponse.IDGAF;
|
return TeleportResponse.IDGAF;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (region.contains(to)) {
|
if (region.contains(to)) {
|
||||||
// Outside -> inside
|
// Outside -> inside
|
||||||
arena.getMessenger().tell(p, Msg.WARP_TO_ARENA);
|
return reject(p, Msg.WARP_TO_ARENA);
|
||||||
return TeleportResponse.REJECT;
|
|
||||||
} else {
|
} else {
|
||||||
// Outside -> outside
|
// Outside -> outside
|
||||||
return TeleportResponse.IDGAF;
|
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) {
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||||
Player p = event.getPlayer();
|
Player p = event.getPlayer();
|
||||||
|
|
||||||
|
@ -369,10 +369,9 @@ public class MAGlobalListener implements Listener
|
|||||||
/*
|
/*
|
||||||
* If we reach this point, no arena has specifically allowed the
|
* If we reach this point, no arena has specifically allowed the
|
||||||
* teleport, but one or more arenas may have rejected it, so we
|
* teleport, but one or more arenas may have rejected it, so we
|
||||||
* may have to cancel the event. If the player has the teleport
|
* may have to cancel the event.
|
||||||
* override permission, however, we don't cancel.
|
|
||||||
*/
|
*/
|
||||||
if (!allow && !event.getPlayer().hasPermission("mobarena.admin.teleport")) {
|
if (!allow) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user