diff --git a/resources/plugin.yml b/resources/plugin.yml index cfd159b..45fc1f6 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.26 +version: 0.95.5.27 softdepend: [Multiverse-Core,Towny,Heroes,MagicSpells,Vault] commands: ma: diff --git a/src/com/garbagemule/MobArena/commands/CommandHandler.java b/src/com/garbagemule/MobArena/commands/CommandHandler.java index b38bf2e..6c2ef67 100644 --- a/src/com/garbagemule/MobArena/commands/CommandHandler.java +++ b/src/com/garbagemule/MobArena/commands/CommandHandler.java @@ -194,6 +194,7 @@ public class CommandHandler implements CommandExecutor register(SetRegionCommand.class); register(SetWarpCommand.class); register(ShowRegionCommand.class); + register(ShowLobbyRegionCommand.class); register(ShowSpawnsCommand.class); register(SpawnpointsCommand.class); register(AutoGenerateCommand.class); diff --git a/src/com/garbagemule/MobArena/commands/setup/ShowLobbyRegionCommand.java b/src/com/garbagemule/MobArena/commands/setup/ShowLobbyRegionCommand.java new file mode 100644 index 0000000..8eecc2a --- /dev/null +++ b/src/com/garbagemule/MobArena/commands/setup/ShowLobbyRegionCommand.java @@ -0,0 +1,69 @@ +package com.garbagemule.MobArena.commands.setup; + +import com.garbagemule.MobArena.Messenger; +import com.garbagemule.MobArena.Msg; +import com.garbagemule.MobArena.commands.Command; +import com.garbagemule.MobArena.commands.CommandInfo; +import com.garbagemule.MobArena.commands.Commands; +import com.garbagemule.MobArena.framework.Arena; +import com.garbagemule.MobArena.framework.ArenaMaster; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandInfo( + name = "showlobbyregion", + pattern = "showlobbyregion", + usage = "/ma showlobbyregion ()", + desc = "show a lobby region", + permission = "mobarena.setup.showlobbyregion" +) +public class ShowLobbyRegionCommand implements Command +{ + @Override + public boolean execute(ArenaMaster am, CommandSender sender, String... args) { + if (!Commands.isPlayer(sender)) { + Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE); + return false; + } + + // Grab the argument, if any. + String arg1 = (args.length > 0 ? args[0] : ""); + + // Cast the sender. + Player p = (Player) sender; + + Arena arena; + + if (arg1.equals("")) { + arena = am.getArenaAtLocation(p.getLocation()); + if (arena == null) { + arena = am.getSelectedArena(); + } + } + else { + arena = am.getArenaWithName(arg1); + + if (arena == null) { + Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST); + return false; + } + } + + if (!arena.getRegion().isLobbyDefined()) { + Messenger.tell(sender, "The lobby region is not defined for the selected arena."); + return false; + } + + // Show an error message if we aren't in the right world + if (!arena.getWorld().getName().equals(arena.getWorld().getName())) { + Messenger.tell(sender, "Arena '" + arena.configName() + + "' is in world '" + arena.getWorld().getName() + + "' and you are in world '" + p.getWorld().getName() + "'"); + return false; + } + + arena.getRegion().showLobbyRegion(p); + + return true; + } +} diff --git a/src/com/garbagemule/MobArena/commands/setup/ShowRegionCommand.java b/src/com/garbagemule/MobArena/commands/setup/ShowRegionCommand.java index 120ca6c..c276505 100644 --- a/src/com/garbagemule/MobArena/commands/setup/ShowRegionCommand.java +++ b/src/com/garbagemule/MobArena/commands/setup/ShowRegionCommand.java @@ -37,11 +37,6 @@ public class ShowRegionCommand implements Command if (arena == null) { arena = am.getSelectedArena(); } - - if (!arena.getRegion().isDefined()) { - Messenger.tell(sender, "The region is not defined for the selected arena."); - return false; - } } else { arena = am.getArenaWithName(arg1); @@ -51,6 +46,11 @@ public class ShowRegionCommand implements Command return false; } } + + if (!arena.getRegion().isDefined()) { + Messenger.tell(sender, "The region is not defined for the selected arena."); + return false; + } // Show an error message if we aren't in the right world if (!arena.getWorld().getName().equals(arena.getWorld().getName())) { diff --git a/src/com/garbagemule/MobArena/region/ArenaRegion.java b/src/com/garbagemule/MobArena/region/ArenaRegion.java index 1925e3c..2539ca8 100644 --- a/src/com/garbagemule/MobArena/region/ArenaRegion.java +++ b/src/com/garbagemule/MobArena/region/ArenaRegion.java @@ -593,7 +593,14 @@ public class ArenaRegion if (!isDefined()) { return; } - showBlocks(p, getFramePoints()); + showBlocks(p, getFramePoints(p1, p2)); + } + + public void showLobbyRegion(final Player p) { + if (!isLobbyDefined()) { + return; + } + showBlocks(p, getFramePoints(l1, l2)); } public void showSpawns(final Player p) { @@ -661,26 +668,26 @@ public class ArenaRegion } }, 100); } - - private List getFramePoints() { + + private List getFramePoints(Location loc1, Location loc2) { List result = new ArrayList(); - int x1 = p1.getBlockX(); int y1 = p1.getBlockY(); int z1 = p1.getBlockZ(); - int x2 = p2.getBlockX(); int y2 = p2.getBlockY(); int z2 = p2.getBlockZ(); - + int x1 = loc1.getBlockX(); int y1 = loc1.getBlockY(); int z1 = loc1.getBlockZ(); + int x2 = loc2.getBlockX(); int y2 = loc2.getBlockY(); int z2 = loc2.getBlockZ(); + for (int i = x1; i <= x2; i++) { result.add(world.getBlockAt(i, y1, z1).getLocation()); result.add(world.getBlockAt(i, y1, z2).getLocation()); result.add(world.getBlockAt(i, y2, z1).getLocation()); result.add(world.getBlockAt(i, y2, z2).getLocation()); } - + for (int j = y1; j <= y2; j++) { result.add(world.getBlockAt(x1, j, z1).getLocation()); result.add(world.getBlockAt(x1, j, z2).getLocation()); result.add(world.getBlockAt(x2, j, z1).getLocation()); result.add(world.getBlockAt(x2, j, z2).getLocation()); } - + for (int k = z1; k <= z2; k++) { result.add(world.getBlockAt(x1, y1, k).getLocation()); result.add(world.getBlockAt(x1, y2, k).getLocation());