mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-27 04:55:25 +01:00
Fix multi-arena join/spec interleaving issues.
- When a player attempts to join or spec an arena while they are in an arena (arena or lobby), they will be denied access. - When a player attempts to join or spec an arena while they are spectating an arena, they will be force-left first.
This commit is contained in:
parent
d57f47fb05
commit
2b5291b593
@ -1,7 +1,7 @@
|
||||
name: MobArena
|
||||
author: garbagemule
|
||||
main: com.garbagemule.MobArena.MobArena
|
||||
version: 0.95.5.10
|
||||
version: 0.95.5.11
|
||||
softdepend: [Spout,Towny,Heroes,MagicSpells,Vault]
|
||||
commands:
|
||||
ma:
|
||||
|
@ -45,6 +45,9 @@ public class JoinCommand implements Command
|
||||
if (!toArena.canJoin(p)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Force leave previous arena
|
||||
if (fromArena != null) fromArena.playerLeave(p);
|
||||
|
||||
// Join the arena!
|
||||
return toArena.playerJoin(p, p.getLocation());
|
||||
|
@ -29,18 +29,28 @@ public class SpecCommand implements Command
|
||||
String arg1 = (args.length > 0 ? args[0] : null);
|
||||
|
||||
// Run some rough sanity checks, and grab the arena to spec.
|
||||
Arena arena = Commands.getArenaToJoinOrSpec(am, p, arg1);
|
||||
if (arena == null) {
|
||||
Arena toArena = Commands.getArenaToJoinOrSpec(am, p, arg1);
|
||||
Arena fromArena = am.getArenaWithPlayer(p);
|
||||
if (toArena == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Deny spectating from other arenas
|
||||
if (fromArena != null && (fromArena.inArena(p) || fromArena.inLobby(p))) {
|
||||
Messenger.tellPlayer(p, Msg.SPEC_ALREADY_PLAYING);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Per-arena sanity checks
|
||||
if (!arena.canSpec(p)) {
|
||||
if (!toArena.canSpec(p)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Force leave previous arena
|
||||
if (fromArena != null) fromArena.playerLeave(p);
|
||||
|
||||
// Spec the arena!
|
||||
arena.playerSpec(p, p.getLocation());
|
||||
toArena.playerSpec(p, p.getLocation());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user