mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-23 11:06:14 +01:00
Add showlobbyregion command.
This commit is contained in:
parent
957545dfe1
commit
69741a3bdc
@ -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:
|
||||
|
@ -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);
|
||||
|
@ -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 (<arena>)",
|
||||
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;
|
||||
}
|
||||
}
|
@ -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())) {
|
||||
|
@ -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<Location> getFramePoints() {
|
||||
|
||||
private List<Location> getFramePoints(Location loc1, Location loc2) {
|
||||
List<Location> result = new ArrayList<Location>();
|
||||
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());
|
||||
|
Loading…
Reference in New Issue
Block a user