mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-02-18 21:41:34 +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
|
name: MobArena
|
||||||
author: garbagemule
|
author: garbagemule
|
||||||
main: com.garbagemule.MobArena.MobArena
|
main: com.garbagemule.MobArena.MobArena
|
||||||
version: 0.95.5.10
|
version: 0.95.5.11
|
||||||
softdepend: [Spout,Towny,Heroes,MagicSpells,Vault]
|
softdepend: [Spout,Towny,Heroes,MagicSpells,Vault]
|
||||||
commands:
|
commands:
|
||||||
ma:
|
ma:
|
||||||
|
@ -46,6 +46,9 @@ public class JoinCommand implements Command
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force leave previous arena
|
||||||
|
if (fromArena != null) fromArena.playerLeave(p);
|
||||||
|
|
||||||
// Join the arena!
|
// Join the arena!
|
||||||
return toArena.playerJoin(p, p.getLocation());
|
return toArena.playerJoin(p, p.getLocation());
|
||||||
}
|
}
|
||||||
|
@ -29,18 +29,28 @@ public class SpecCommand implements Command
|
|||||||
String arg1 = (args.length > 0 ? args[0] : null);
|
String arg1 = (args.length > 0 ? args[0] : null);
|
||||||
|
|
||||||
// Run some rough sanity checks, and grab the arena to spec.
|
// Run some rough sanity checks, and grab the arena to spec.
|
||||||
Arena arena = Commands.getArenaToJoinOrSpec(am, p, arg1);
|
Arena toArena = Commands.getArenaToJoinOrSpec(am, p, arg1);
|
||||||
if (arena == null) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Per-arena sanity checks
|
// Per-arena sanity checks
|
||||||
if (!arena.canSpec(p)) {
|
if (!toArena.canSpec(p)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force leave previous arena
|
||||||
|
if (fromArena != null) fromArena.playerLeave(p);
|
||||||
|
|
||||||
// Spec the arena!
|
// Spec the arena!
|
||||||
arena.playerSpec(p, p.getLocation());
|
toArena.playerSpec(p, p.getLocation());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user