diff --git a/resources/plugin.yml b/resources/plugin.yml index bb48596..3586766 100644 --- a/resources/plugin.yml +++ b/resources/plugin.yml @@ -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: diff --git a/src/com/garbagemule/MobArena/commands/user/JoinCommand.java b/src/com/garbagemule/MobArena/commands/user/JoinCommand.java index ef55c45..e22a56a 100644 --- a/src/com/garbagemule/MobArena/commands/user/JoinCommand.java +++ b/src/com/garbagemule/MobArena/commands/user/JoinCommand.java @@ -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()); diff --git a/src/com/garbagemule/MobArena/commands/user/SpecCommand.java b/src/com/garbagemule/MobArena/commands/user/SpecCommand.java index 81bb2ac..08558a0 100644 --- a/src/com/garbagemule/MobArena/commands/user/SpecCommand.java +++ b/src/com/garbagemule/MobArena/commands/user/SpecCommand.java @@ -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; } }