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:
garbagemule 2013-08-06 12:21:06 +02:00
parent d57f47fb05
commit 2b5291b593
3 changed files with 18 additions and 5 deletions

View File

@ -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:

View File

@ -46,6 +46,9 @@ public class JoinCommand implements Command
return false;
}
// Force leave previous arena
if (fromArena != null) fromArena.playerLeave(p);
// Join the arena!
return toArena.playerJoin(p, p.getLocation());
}

View File

@ -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;
}
}