Tidy up commands.

- The execute() method has had its docs redefined to reflect how the
  CommandHandler now handles the return value of the method. That is,
  if the method returns false, the CommandHandler prints the usage
  message and description of the command to the command sender.
- Commands now only return false when they should, according to the
  updated docs of the execute() method.
- Most commands have been tidied up a bit, i.e. they've had some
  unnecessary code removed in the advent of the new usage printing
  of the CommandHandler.
- Some commands have had their patterns altered slightly.
- The order of command registration now matters. That is, the order
  commands are registered in will be the order in which the help
  screen will display the command usages and descriptions.
- The help screen now shows ordered commands, and separates the
  types into user, admin and setup sections for a better overview.
This commit is contained in:
garbagemule 2013-08-20 16:36:28 +02:00
parent e7d3da4db3
commit eb04693c3f
42 changed files with 308 additions and 459 deletions

View File

@ -8,13 +8,22 @@ public interface Command
{
/**
* Execute the command using the given arguments.
* If any arguments are provided, the first argument is -NOT- the
* same as the command name, i.e. the CommandHandler must strip the
* array of this element.
* <p>
* If the method returns false, the command handler will print the usage
* message (usage + description) for the command, and as such, if the
* execution was successful in any way, the method should return true.
* Note that "successful in any way" means if the execution managed to
* complete in the sense that it itself prints a message to the sender,
* or otherwise executed properly, not if the intent of the command
* wasn't fulfilled. Typically, this means that false is only returned
* if the command was executed with a set of arguments that did not
* match the usage message.
*
* @param am an ArenaMaster instance
* @param sender the sender
* @param args array of arguments
* @return true, if the command was successful
* @return true, if the command succeeded in any way, false if the
* command handler should print the usage message to the sender
*/
public boolean execute(ArenaMaster am, CommandSender sender, String... args);
}

View File

@ -1,10 +1,6 @@
package com.garbagemule.MobArena.commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.Map.Entry;
import org.bukkit.ChatColor;
@ -56,7 +52,7 @@ public class CommandHandler implements CommandExecutor
if (matches.size() > 1) {
Messenger.tell(sender, Msg.MISC_MULTIPLE_MATCHES);
for (Command cmd : matches) {
showUsage(cmd, sender);
showUsage(cmd, sender, false);
}
return true;
}
@ -79,13 +75,15 @@ public class CommandHandler implements CommandExecutor
// Check if the last argument is a ?, in which case, display usage and description
if (last.equals("?") || last.equals("help")) {
showUsage(command, sender);
showUsage(command, sender, true);
return true;
}
// Otherwise, execute the command!
String[] params = trimFirstArg(args);
command.execute(am, sender, params);
if (!command.execute(am, sender, params)) {
showUsage(command, sender, true);
}
return true;
}
@ -113,11 +111,11 @@ public class CommandHandler implements CommandExecutor
* @param cmd a Command
* @param sender a CommandSender
*/
private void showUsage(Command cmd, CommandSender sender) {
private void showUsage(Command cmd, CommandSender sender, boolean prefix) {
CommandInfo info = cmd.getClass().getAnnotation(CommandInfo.class);
if (!plugin.has(sender, info.permission())) return;
sender.sendMessage(info.usage() + " " + ChatColor.YELLOW + info.desc());
sender.sendMessage((prefix ? "Usage: " : "") + info.usage() + " " + ChatColor.YELLOW + info.desc());
}
/**
@ -135,10 +133,33 @@ public class CommandHandler implements CommandExecutor
* @param sender a player or the console
*/
private void showHelp(CommandSender sender) {
Messenger.tell(sender, "Available MobArena commands:");
StringBuilder user = new StringBuilder();
StringBuilder admin = new StringBuilder();
StringBuilder setup = new StringBuilder();
for (Command cmd : commands.values()) {
showUsage(cmd, sender);
CommandInfo info = cmd.getClass().getAnnotation(CommandInfo.class);
if (!plugin.has(sender, info.permission())) continue;
StringBuilder buffy;
if (info.permission().startsWith("mobarena.admin")) {
buffy = admin;
} else if (info.permission().startsWith("mobarena.setup")) {
buffy = setup;
} else {
buffy = user;
}
buffy.append("\n")
.append(ChatColor.RESET).append(info.usage()).append(" ")
.append(ChatColor.YELLOW).append(info.desc());
}
if (admin.length() == 0 && setup.length() == 0) {
Messenger.tell(sender, "Available commands: " + user.toString());
} else {
Messenger.tell(sender, "User commands: " + user.toString());
if (admin.length() > 0) Messenger.tell(sender, "Admin commands: " + admin.toString());
if (setup.length() > 0) Messenger.tell(sender, "Setup commands: " + setup.toString());
}
}
@ -148,57 +169,64 @@ public class CommandHandler implements CommandExecutor
* method, but this is neater, albeit more manual work.
*/
private void registerCommands() {
commands = new HashMap<String,Command>();
commands = new LinkedHashMap<String,Command>();
// mobarena.use
register(ArenaListCommand.class);
register(JoinCommand.class);
register(LeaveCommand.class);
register(NotReadyCommand.class);
register(SpecCommand.class);
register(ArenaListCommand.class);
register(PlayerListCommand.class);
register(NotReadyCommand.class);
// mobarena.admin
register(DisableCommand.class);
register(EnableCommand.class);
register(DisableCommand.class);
register(ForceCommand.class);
register(KickCommand.class);
register(RestoreCommand.class);
// mobarena.setup
register(AddArenaCommand.class);
register(AddClassPermCommand.class);
register(AddContainerCommand.class);
register(AddSpawnpointCommand.class);
register(ArenaCommand.class);
register(CheckDataCommand.class);
register(CheckSpawnsCommand.class);
register(ConfigCommand.class);
register(ContainersCommand.class);
register(EditArenaCommand.class);
register(ExpandLobbyRegionCommand.class);
register(ExpandRegionCommand.class);
register(ListClassesCommand.class);
register(ListClassPermsCommand.class);
register(ProtectCommand.class);
register(AddArenaCommand.class);
register(RemoveArenaCommand.class);
register(RemoveClassCommand.class);
register(RemoveClassPermCommand.class);
register(RemoveContainerCommand.class);
register(RemoveLeaderboardCommand.class);
register(RemoveSpawnpointCommand.class);
register(EditArenaCommand.class);
register(ArenaCommand.class);
register(SetArenaCommand.class);
register(SetClassCommand.class);
register(SetLobbyRegionCommand.class);
register(SetRegionCommand.class);
register(SetWarpCommand.class);
register(SetRegionCommand.class);
register(SetLobbyRegionCommand.class);
register(ExpandRegionCommand.class);
register(ExpandLobbyRegionCommand.class);
register(ShowRegionCommand.class);
register(ShowLobbyRegionCommand.class);
register(CheckDataCommand.class);
register(ShowSpawnsCommand.class);
register(SpawnpointsCommand.class);
register(AddSpawnpointCommand.class);
register(RemoveSpawnpointCommand.class);
register(CheckSpawnsCommand.class);
register(ContainersCommand.class);
register(AddContainerCommand.class);
register(RemoveContainerCommand.class);
register(ListClassesCommand.class);
register(SetClassCommand.class);
register(RemoveClassCommand.class);
register(ClassChestCommand.class);
register(ListClassPermsCommand.class);
register(AddClassPermCommand.class);
register(RemoveClassPermCommand.class);
register(ProtectCommand.class);
register(RemoveLeaderboardCommand.class);
register(AutoGenerateCommand.class);
register(AutoDegenerateCommand.class);
register(ClassChestCommand.class);
}
/**

View File

@ -33,9 +33,8 @@ public class DisableCommand implements Command
Arena arena = am.getArenaWithName(arg1);
if (arena == null) {
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
return false;
return true;
}
disable(arena, sender);
return true;
}
@ -43,7 +42,6 @@ public class DisableCommand implements Command
am.setEnabled(false);
am.saveConfig();
Messenger.tell(sender, "MobArena " + ChatColor.RED + "disabled");
return true;
}

View File

@ -33,9 +33,8 @@ public class EnableCommand implements Command
Arena arena = am.getArenaWithName(arg1);
if (arena == null) {
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
return false;
return true;
}
enable(arena, sender);
return true;
}
@ -43,7 +42,6 @@ public class EnableCommand implements Command
am.setEnabled(true);
am.saveConfig();
Messenger.tell(sender, "MobArena " + ChatColor.GREEN + "enabled");
return true;
}

View File

@ -18,6 +18,9 @@ public class ForceCommand implements Command
{
@Override
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
// Require at least one argument
if (args.length < 1) return false;
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
String arg2 = (args.length > 1 ? args[1] : "");
@ -28,7 +31,6 @@ public class ForceCommand implements Command
for (Arena arena : am.getArenas()) {
arena.forceEnd();
}
Messenger.tell(sender, Msg.FORCE_END_ENDED);
am.resetArenaMap();
return true;
@ -38,53 +40,46 @@ public class ForceCommand implements Command
Arena arena = am.getArenaWithName(arg2);
if (arena == null) {
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
return false;
return true;
}
if (arena.getAllPlayers().isEmpty()) {
Messenger.tell(sender, Msg.FORCE_END_EMPTY);
return false;
return true;
}
// And end it!
arena.forceEnd();
Messenger.tell(sender, Msg.FORCE_END_ENDED);
return true;
}
if (arg1.equals("start")) {
// Require argument.
if (arg2.equals("")) {
Messenger.tell(sender, "Usage: /ma force start <arena>");
return false;
}
if (arg2.equals("")) return false;
// Grab the arena.
Arena arena = am.getArenaWithName(arg2);
if (arena == null) {
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
return false;
return true;
}
if (arena.isRunning()) {
Messenger.tell(sender, Msg.FORCE_START_RUNNING);
return false;
return true;
}
if (arena.getReadyPlayersInLobby().isEmpty()) {
Messenger.tell(sender, Msg.FORCE_START_NOT_READY);
return false;
return true;
}
// And start it!
arena.forceStart();
Messenger.tell(sender, Msg.FORCE_START_STARTED);
return true;
}
Messenger.tell(sender, "Usage: /ma force start|end (<arena name>)");
return true;
return false;
}
}

View File

@ -19,28 +19,21 @@ public class KickCommand implements Command
{
@Override
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
// Require a player name
if (args.length != 1) return false;
// Require an argument
if (arg1.equals("")) {
Messenger.tell(sender, "Usage: /ma kick <player>");
return false;
}
Arena arena = am.getArenaWithPlayer(arg1);
Arena arena = am.getArenaWithPlayer(args[0]);
if (arena == null) {
Messenger.tell(sender, "That player is not in an arena.");
return false;
return true;
}
// Grab the Player object.
Player bp = am.getPlugin().getServer().getPlayer(arg1);
Player bp = am.getPlugin().getServer().getPlayer(args[0]);
// Force leave.
arena.playerLeave(bp);
Messenger.tell(sender, "Player '" + arg1 + "' was kicked from arena '" + arena.configName() + "'.");
Messenger.tell(sender, "Player '" + args[0] + "' was kicked from arena '" + arena.configName() + "'.");
Messenger.tell(bp, "You were kicked by " + sender.getName() + ".");
return true;
}

View File

@ -18,26 +18,19 @@ public class RestoreCommand implements Command
{
@Override
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
// Require a player name
if (args.length != 1) return false;
// Require an argument
if (arg1.equals("")) {
Messenger.tell(sender, "Usage: /ma restore <player>");
return false;
}
if (am.getArenaWithPlayer(arg1) != null) {
if (am.getArenaWithPlayer(args[0]) != null) {
Messenger.tell(sender, "Player is currently in an arena.");
return false;
return true;
}
if (InventoryManager.restoreFromFile(am.getPlugin(), am.getPlugin().getServer().getPlayer(arg1))) {
Messenger.tell(sender, "Restored " + arg1 + "'s inventory!");
if (InventoryManager.restoreFromFile(am.getPlugin(), am.getPlugin().getServer().getPlayer(args[0]))) {
Messenger.tell(sender, "Restored " + args[0] + "'s inventory!");
} else {
Messenger.tell(sender, "Failed to restore " + arg1 + "'s inventory.");
Messenger.tell(sender, "Failed to restore " + args[0] + "'s inventory.");
}
return true;
}
}

View File

@ -21,31 +21,25 @@ public class AddArenaCommand implements Command
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
if (!Commands.isPlayer(sender)) {
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
return false;
return true;
}
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
// Require an arena name
if (args.length != 1) return false;
// Cast the sender.
Player p = (Player) sender;
// Require an argument
if (arg1.equals("")) {
Messenger.tell(sender, "Usage: /ma addarena <arena>");
return true;
}
Arena arena = am.getArenaWithName(arg1);
Arena arena = am.getArenaWithName(args[0]);
if (arena != null) {
Messenger.tell(sender, "An arena with that name already exists.");
return true;
}
arena = am.createArenaNode(arg1, p.getWorld());
arena = am.createArenaNode(args[0], p.getWorld());
am.setSelectedArena(arena);
Messenger.tell(sender, "New arena with name '" + arg1 + "' created!");
Messenger.tell(sender, "New arena with name '" + args[0] + "' created!");
return true;
}
}

View File

@ -18,30 +18,24 @@ public class AddClassPermCommand implements Command
{
@Override
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
String arg2 = (args.length > 1 ? args[1] : "");
if (arg1.equals("") || arg2.equals("")) {
Messenger.tell(sender, "Usage: /ma addclassperm <classname> <permission>");
return false;
}
// Require classname and permission
if (args.length != 2) return false;
// Grab the arena class
ArenaClass arenaClass = am.getClasses().get(arg1);
ArenaClass arenaClass = am.getClasses().get(args[0]);
if (arenaClass == null) {
Messenger.tell(sender, "The class '" + TextUtils.camelCase(arg1) + "' does not exist.");
return false;
Messenger.tell(sender, "The class '" + TextUtils.camelCase(args[0]) + "' does not exist.");
return true;
}
// Try to add the permission.
if (am.addClassPermission(arg1, arg2)) {
Messenger.tell(sender, "Added permission '" + arg2 + "' to class '" + TextUtils.camelCase(arg1) + "'.");
if (am.addClassPermission(args[0], args[1])) {
Messenger.tell(sender, "Added permission '" + args[1] + "' to class '" + TextUtils.camelCase(args[0]) + "'.");
return true;
}
// If it wasn't added, notify.
Messenger.tell(sender, "Permission '" + arg2 + "' was NOT added to class '" + TextUtils.camelCase(arg1) + "'.");
return false;
Messenger.tell(sender, "Permission '" + args[1] + "' was NOT added to class '" + TextUtils.camelCase(args[0]) + "'.");
return true;
}
}

View File

@ -21,27 +21,23 @@ public class AddContainerCommand implements Command
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
if (!Commands.isPlayer(sender)) {
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
return false;
return true;
}
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
// Require a point name
if (args.length != 1 || args[0].matches("^[a-zA-Z][a-zA-Z0-9]*$")) return false;
// Cast the sender.
Player p = (Player) sender;
if (!arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$")) {
Messenger.tell(sender, "Usage: /ma addcontainer <point name>");
return false;
}
// Make sure we're looking at a container
if (!(p.getTargetBlock(null, 50).getState() instanceof InventoryHolder)) {
Messenger.tell(sender, "You must look at container.");
return false;
return true;
}
am.getSelectedArena().getRegion().addChest(arg1, p.getTargetBlock(null, 50).getLocation());
Messenger.tell(sender, "Container '" + arg1 + "' added for arena \"" + am.getSelectedArena().configName() + "\"");
am.getSelectedArena().getRegion().addChest(args[0], p.getTargetBlock(null, 50).getLocation());
Messenger.tell(sender, "Container '" + args[0] + "' added for arena \"" + am.getSelectedArena().configName() + "\"");
return true;
}
}

View File

@ -22,19 +22,14 @@ public class AddSpawnpointCommand implements Command
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
if (!Commands.isPlayer(sender)) {
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
return false;
return true;
}
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
// Require a point name
if (args.length != 1 || args[0].matches("^[a-zA-Z][a-zA-Z0-9]*$")) return false;
// Cast the sender.
Player p = (Player) sender;
if (!arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$")) {
Messenger.tell(sender, "Usage: /ma addspawn <point name>");
return true;
}
// Make a world check first
Arena arena = am.getSelectedArena();
@ -57,7 +52,7 @@ public class AddSpawnpointCommand implements Command
if (changeWorld) arena.setWorld(aw);
} else {
// Add the spawnpoint
am.getSelectedArena().getRegion().addSpawn(arg1, p.getLocation());
am.getSelectedArena().getRegion().addSpawn(args[0], p.getLocation());
// Notify the player if world changed
if (changeWorld) {
@ -67,7 +62,7 @@ public class AddSpawnpointCommand implements Command
}
// Then notify about point set
Messenger.tell(sender, "Spawnpoint '" + arg1 + "' added for arena '" + am.getSelectedArena().configName() + "'");
Messenger.tell(sender, "Spawnpoint '" + args[0] + "' added for arena '" + am.getSelectedArena().configName() + "'");
arena.getRegion().checkData(am.getPlugin(), sender, false, false, false, true);
}
return true;

View File

@ -18,33 +18,28 @@ public class AutoDegenerateCommand implements Command
{
@Override
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
// Grab the arguments, if any.
String arg1 = (args.length > 0 ? args[0] : "");
// Require an arena name
if (args.length != 1) return false;
// Require an argument
if (arg1.equals("")) {
Messenger.tell(sender, "Usage: /ma autodegenerate <arena>");
return true;
}
// We have to make sure at least one arena exists before degenerating
if (am.getArenas().size() < 2) {
Messenger.tell(sender, "At least one arena must exist!");
return true;
}
// Check if arena exists.
Arena arena = am.getArenaWithName(arg1);
Arena arena = am.getArenaWithName(args[0]);
if (arena == null) {
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
return true;
}
if (!MAUtils.undoItHippieMonster(arg1, am.getPlugin(), true)) {
if (!MAUtils.undoItHippieMonster(args[0], am.getPlugin(), true)) {
Messenger.tell(sender, "Could not degenerate arena.");
return true;
}
Messenger.tell(sender, "Arena with name '" + arg1 + "' degenerated.");
Messenger.tell(sender, "Arena with name '" + args[0] + "' degenerated.");
return true;
}
}

View File

@ -21,34 +21,28 @@ public class AutoGenerateCommand implements Command
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
if (!Commands.isPlayer(sender)) {
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
return false;
return true;
}
// Grab the arguments, if any.
String arg1 = (args.length > 0 ? args[0] : "");
// Require an arena name
if (args.length != 1) return false;
// Cast the sender.
Player p = (Player) sender;
// Require an argument
if (arg1.equals("")) {
Messenger.tell(sender, "Usage: /ma autogenerate <arena>");
return true;
}
// Check if arena already exists.
Arena arena = am.getArenaWithName(arg1);
Arena arena = am.getArenaWithName(args[0]);
if (arena != null) {
Messenger.tell(sender, "An arena with that name already exists.");
return true;
}
if (!MAUtils.doooooItHippieMonster(p.getLocation(), 13, arg1, am.getPlugin())) {
if (!MAUtils.doooooItHippieMonster(p.getLocation(), 13, args[0], am.getPlugin())) {
Messenger.tell(sender, "Could not auto-generate arena.");
return true;
}
Messenger.tell(sender, "Arena with name '" + arg1 + "' generated.");
Messenger.tell(sender, "Arena with name '" + args[0] + "' generated.");
return true;
}
}

View File

@ -10,7 +10,7 @@ import com.garbagemule.MobArena.framework.ArenaMaster;
@CommandInfo(
name = "checkdata",
pattern = "checkdata",
usage = "/ma checkdata",
usage = "/ma checkdata (<arena>)",
desc = "check if all required points are set up",
permission = "mobarena.setup.checkdata"
)
@ -24,7 +24,7 @@ public class CheckDataCommand implements Command
Arena arena = arg1.equals("") ? am.getSelectedArena() : am.getArenaWithName(arg1);
if (arena == null) {
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
return false;
return true;
}
arena.getRegion().checkData(am.getPlugin(), sender, true, true, true, true);

View File

@ -23,7 +23,7 @@ public class CheckSpawnsCommand implements Command
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
if (!Commands.isPlayer(sender)) {
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
return false;
return true;
}
// Grab the argument, if any.
@ -33,29 +33,23 @@ public class CheckSpawnsCommand implements Command
Player p = (Player) sender;
Arena arena;
if (arg1.equals("")) {
arena = am.getArenaAtLocation(p.getLocation());
if (arena == null) {
arena = am.getSelectedArena();
}
if (arena.getRegion().getSpawnpoints().isEmpty()) {
Messenger.tell(sender, "There are no spawnpoints in the selected arena.");
return false;
return true;
}
}
else {
} else {
arena = am.getArenaWithName(arg1);
if (arena == null) {
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
return false;
return true;
}
}
arena.getRegion().checkSpawns(p);
return true;
}
}

View File

@ -26,14 +26,12 @@ public class ClassChestCommand implements Command {
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
if (!Commands.isPlayer(sender)) {
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
return false;
}
if (args.length != 1) {
Messenger.tell(sender, "Usage: /ma classchest <class>");
return true;
}
// Require a class name
if (args.length != 1) return false;
ArenaClass ac = am.getClasses().get(args[0].toLowerCase());
if (ac == null) {
Messenger.tell(sender, "Class not found.");

View File

@ -17,23 +17,18 @@ public class ConfigCommand implements Command
{
@Override
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
if (arg1.equals("reload")) {
// Require reload/save
if (args.length != 1) return false;
if (args[0].equals("reload")) {
am.reloadConfig();
Messenger.tell(sender, "Config reloaded.");
return true;
}
if (arg1.equals("save")) {
} else if (args[0].equals("save")) {
am.saveConfig();
Messenger.tell(sender, "Config saved.");
return true;
} else {
return false;
}
// Requires an argument.
Messenger.tell(sender, "Usage: /ma config reload|save");
return false;
return true;
}
}

View File

@ -36,15 +36,13 @@ public class EditArenaCommand implements Command
// Argument is [true|false]
if (arg1.matches("true|on") || arg1.matches("false|off")) {
arena = am.getSelectedArena();
arena.setEditMode(arg1.equals("true"));
arena.setEditMode(arg1.matches("true|on"));
}
// Argument is <arena name>
else {
arena = am.getArenaWithName(arg1);
if (arena == null) {
Messenger.tell(sender, "There is no arena with that name.");
Messenger.tell(sender, "Usage: /ma editarena (true|false)");
Messenger.tell(sender, " or /ma editarena <arena> (true|false)");
return true;
}
arena.setEditMode(!arena.inEditMode());
@ -54,18 +52,14 @@ public class EditArenaCommand implements Command
// Two arguments
else {
if (!(arg2.matches("true|on") || arg2.matches("false|off"))) {
Messenger.tell(sender, "Usage: /ma editarena (true|false)");
Messenger.tell(sender, " or /ma editarena <arena> (true|false)");
return true;
return false;
}
arena = am.getArenaWithName(arg1);
if (arena == null) {
Messenger.tell(sender, "There is no arena with that name.");
Messenger.tell(sender, "Usage: /ma editarena (true|false)");
Messenger.tell(sender, " or /ma editarena <arena> (true|false)");
return true;
}
arena.setEditMode(arg2.equals("true"));
arena.setEditMode(arg2.matches("true|on"));
}
Messenger.tell(sender, "Edit mode for arena '" + arena.configName() + "': " + ((arena.inEditMode()) ? ChatColor.GREEN + "true" : ChatColor.RED + "false"));

View File

@ -17,40 +17,29 @@ public class ExpandLobbyRegionCommand implements Command
{
@Override
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
String arg2 = (args.length > 1 ? args[1] : "");
if (args.length != 2 || !arg1.matches("(-)?[0-9]+")) {
Messenger.tell(sender, "Usage: /ma expandlobbyregion <amount> up|down|out");
return false;
}
// Require amount and direction
if (args.length != 2 || !args[0].matches("(-)?[0-9]+")) return false;
if (!am.getSelectedArena().getRegion().isLobbyDefined()) {
Messenger.tell(sender, "You must first define l1 and l2");
return true;
}
if (arg2.equals("up")) {
am.getSelectedArena().getRegion().expandLobbyUp(Integer.parseInt(arg1));
}
else if (arg2.equals("down")) {
am.getSelectedArena().getRegion().expandLobbyDown(Integer.parseInt(arg1));
}
else if (arg2.equals("out")) {
am.getSelectedArena().getRegion().expandLobbyOut(Integer.parseInt(arg1));
}
else {
Messenger.tell(sender, "Usage: /ma expandlobbyregion <amount> up|down|out");
return true;
if (args[1].equals("up")) {
am.getSelectedArena().getRegion().expandLobbyUp(Integer.parseInt(args[0]));
} else if (args[1].equals("down")) {
am.getSelectedArena().getRegion().expandLobbyDown(Integer.parseInt(args[0]));
} else if (args[1].equals("out")) {
am.getSelectedArena().getRegion().expandLobbyOut(Integer.parseInt(args[0]));
} else {
return false;
}
// In case of a "negative" region, fix it!
am.getSelectedArena().getRegion().fixLobbyRegion();
Messenger.tell(sender, "Lobby region for '" + am.getSelectedArena().configName() + "' expanded " + arg2 + " by " + arg1 + " blocks.");
Messenger.tell(sender, "Lobby region for '" + am.getSelectedArena().configName() + "' expanded " + args[1] + " by " + args[0] + " blocks.");
am.getSelectedArena().getRegion().save();
return true;
}
}

View File

@ -17,40 +17,29 @@ public class ExpandRegionCommand implements Command
{
@Override
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
String arg2 = (args.length > 1 ? args[1] : "");
if (args.length != 2 || !arg1.matches("(-)?[0-9]+")) {
Messenger.tell(sender, "Usage: /ma expandregion <amount> up|down|out");
return false;
}
// Require amount and direction
if (args.length != 2 || !args[0].matches("(-)?[0-9]+")) return false;
if (!am.getSelectedArena().getRegion().isDefined()) {
Messenger.tell(sender, "You must first define p1 and p2");
return true;
}
if (arg2.equals("up")) {
am.getSelectedArena().getRegion().expandUp(Integer.parseInt(arg1));
}
else if (arg2.equals("down")) {
am.getSelectedArena().getRegion().expandDown(Integer.parseInt(arg1));
}
else if (arg2.equals("out")) {
am.getSelectedArena().getRegion().expandOut(Integer.parseInt(arg1));
}
else {
Messenger.tell(sender, "Usage: /ma expandregion <amount> up|down|out");
return true;
if (args[1].equals("up")) {
am.getSelectedArena().getRegion().expandUp(Integer.parseInt(args[0]));
} else if (args[1].equals("down")) {
am.getSelectedArena().getRegion().expandDown(Integer.parseInt(args[0]));
} else if (args[1].equals("out")) {
am.getSelectedArena().getRegion().expandOut(Integer.parseInt(args[0]));
} else {
return false;
}
// In case of a "negative" region, fix it!
am.getSelectedArena().getRegion().fixRegion();
Messenger.tell(sender, "Region for '" + am.getSelectedArena().configName() + "' expanded " + arg2 + " by " + arg1 + " blocks.");
Messenger.tell(sender, "Region for '" + am.getSelectedArena().configName() + "' expanded " + args[1] + " by " + args[0] + " blocks.");
am.getSelectedArena().getRegion().save();
return true;
}
}

View File

@ -21,17 +21,11 @@ public class ListClassPermsCommand implements Command
{
@Override
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
// Require a class name
if (args.length != 1) return false;
// Require an argument.
if (arg1.equals("")) {
Messenger.tell(sender, "Usage: /ma listclassperms <classname>");
return true;
}
ArenaClass arenaClass = am.getClasses().get(arg1);
String className = TextUtils.camelCase(arg1);
ArenaClass arenaClass = am.getClasses().get(args[0]);
String className = TextUtils.camelCase(args[0]);
if (arenaClass == null) {
Messenger.tell(sender, "The class '" + className + "' does not exist.");

View File

@ -43,8 +43,6 @@ public class ProtectCommand implements Command
arena = am.getArenaWithName(arg1);
if (arena == null) {
Messenger.tell(sender, "There is no arena with that name.");
Messenger.tell(sender, "Usage: /ma protect (true|false)");
Messenger.tell(sender, " or /ma protect <arena> (true|false)");
return true;
}
arena.setProtected(!arena.isProtected());
@ -54,18 +52,14 @@ public class ProtectCommand implements Command
// Two arguments
else {
if (!(arg2.matches("true|on") || arg2.matches("false|off"))) {
Messenger.tell(sender, "Usage: /ma protect (true|false)");
Messenger.tell(sender, " or /ma protect <arena name> (true|false)");
return true;
return false;
}
arena = am.getArenaWithName(arg1);
if (arena == null) {
Messenger.tell(sender, "There is no arena with that name.");
Messenger.tell(sender, "Usage: /ma protect (true|false)");
Messenger.tell(sender, " or /ma protect <arena name> (true|false)");
return true;
}
arena.setProtected(arg2.equals("true"));
arena.setProtected(arg2.matches("true|on"));
}
arena.getPlugin().saveConfig();

View File

@ -18,24 +18,18 @@ public class RemoveArenaCommand implements Command
{
@Override
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
// Require an argument
if (arg1.equals("")) {
Messenger.tell(sender, "Usage: /ma removearena <arena>");
return false;
}
// Require an arena name
if (args.length != 1) return false;
if (am.getArenas().size() == 1) {
Messenger.tell(sender, "At least one arena must exist.");
return false;
return true;
}
Arena arena = am.getArenaWithName(arg1);
Arena arena = am.getArenaWithName(args[0]);
if (arena == null) {
Messenger.tell(sender, "There is no arena with that name.");
return false;
return true;
}
am.removeArenaNode(arena);

View File

@ -18,21 +18,15 @@ public class RemoveClassCommand implements Command
{
@Override
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
// Require an argument.
if (arg1.equals("")) {
Messenger.tell(sender, "Usage: /ma removeclass <classname>");
return false;
}
// Require a class name
if (args.length != 1) return false;
// Find the class
ArenaClass arenaClass = am.getClasses().get(arg1);
String className = TextUtils.camelCase(arg1);
ArenaClass arenaClass = am.getClasses().get(args[0]);
String className = TextUtils.camelCase(args[0]);
if (arenaClass == null) {
Messenger.tell(sender, "The class '" + className + "' does not exist.");
return false;
return true;
}
am.removeClassNode(className);

View File

@ -18,30 +18,24 @@ public class RemoveClassPermCommand implements Command
{
@Override
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
String arg2 = (args.length > 1 ? args[1] : "");
if (arg1.equals("") || arg2.equals("")) {
Messenger.tell(sender, "Usage: /ma removeclassperm <classname> <permission>");
return false;
}
// Require class name and permission
if (args.length != 2) return false;
// Grab the arena class
ArenaClass arenaClass = am.getClasses().get(arg1);
ArenaClass arenaClass = am.getClasses().get(args[0]);
if (arenaClass == null) {
Messenger.tell(sender, "The class '" + TextUtils.camelCase(arg1) + "' does not exist.");
return false;
Messenger.tell(sender, "The class '" + TextUtils.camelCase(args[0]) + "' does not exist.");
return true;
}
// Remove the permission.
if (am.removeClassPermission(arg1, arg2)) {
Messenger.tell(sender, "Removed permission '" + arg2 + "' from class '" + TextUtils.camelCase(arg1) + "'.");
if (am.removeClassPermission(args[0], args[1])) {
Messenger.tell(sender, "Removed permission '" + args[1] + "' from class '" + TextUtils.camelCase(args[0]) + "'.");
return true;
}
// If it wasn't removed, notify.
Messenger.tell(sender, "Permission '" + arg2 + "' was NOT removed from class '" + TextUtils.camelCase(arg1) + "'.");
return false;
Messenger.tell(sender, "Permission '" + args[1] + "' was NOT removed from class '" + TextUtils.camelCase(args[0]) + "'.");
return true;
}
}

View File

@ -17,19 +17,14 @@ public class RemoveContainerCommand implements Command
{
@Override
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
// Require a point name
if (args.length != 1 || !args[0].matches("^[a-zA-Z][a-zA-Z0-9]*$")) return false;
// Require an argument
if (!arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$")) {
Messenger.tell(sender, "Usage: /ma removecontainer <point name>");
return false;
if (am.getSelectedArena().getRegion().removeChest(args[0])) {
Messenger.tell(sender, "Container " + args[0] + " removed for arena '" + am.getSelectedArena().configName() + "'");
} else {
Messenger.tell(sender, "Could not find the container " + args[0] + "for the arena '" + am.getSelectedArena().configName() + "'");
}
if (am.getSelectedArena().getRegion().removeChest(arg1))
Messenger.tell(sender, "Container " + arg1 + " removed for arena '" + am.getSelectedArena().configName() + "'");
else
Messenger.tell(sender, "Could not find the container " + arg1 + "for the arena '" + am.getSelectedArena().configName() + "'");
return true;
}
}

View File

@ -9,14 +9,14 @@ import com.garbagemule.MobArena.commands.CommandInfo;
import com.garbagemule.MobArena.framework.ArenaMaster;
@CommandInfo(
name = "removeleaderboard",
pattern = "(del(.)*|r(e)?m(ove)?)leaderboard",
usage = "/ma removeleaderboard <arenaname>",
desc = "remove the selected arena's leaderboard",
permission = "mobarena.setup.leaderboards"
)
public class RemoveLeaderboardCommand implements Command{
name = "removeleaderboard",
pattern = "(del(.)*|r(e)?m(ove)?)leaderboard",
usage = "/ma removeleaderboard (<arena>)",
desc = "remove the selected arena's leaderboard",
permission = "mobarena.setup.leaderboards"
)
public class RemoveLeaderboardCommand implements Command
{
@Override
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
// Grab the argument, if any.
@ -28,29 +28,22 @@ public class RemoveLeaderboardCommand implements Command{
am.getSelectedArena().getRegion().set("leaderboard", null);
Messenger.tell(sender, "Leaderboard for " + am.getSelectedArena().arenaName() + " successfully removed!");
return true;
}
else {
} else {
Messenger.tell(sender, Msg.ARENA_LBOARD_NOT_FOUND);
}
}
else {
} else {
if (am.getArenaWithName(arg1) != null) {
if (am.getSelectedArena().getRegion().getLeaderboard() != null) {
am.getArenaWithName(arg1).getRegion().set("leaderboard", null);
Messenger.tell(sender, "Leaderboard for " + am.getArenaWithName(arg1).arenaName() + " successfully removed!");
return true;
}
else {
} else {
Messenger.tell(sender, Msg.ARENA_LBOARD_NOT_FOUND);
}
}
else {
Messenger.tell(sender, "Usage: /ma removeleaderboard <arenaname>");
return false;
} else {
Messenger.tell(sender, "No arena with that name exists.");
}
}
return false;
return true;
}
}

View File

@ -17,19 +17,14 @@ public class RemoveSpawnpointCommand implements Command
{
@Override
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
// Require a point name
if (args.length != 1 || !args[0].matches("^[a-zA-Z][a-zA-Z0-9]*$")) return false;
// Require an argument
if (!arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$")) {
Messenger.tell(sender, "Usage: /ma removespawn <point name>");
return true;
if (am.getSelectedArena().getRegion().removeSpawn(args[0])) {
Messenger.tell(sender, "Spawnpoint " + args[0] + " removed for arena '" + am.getSelectedArena().configName() + "'");
} else {
Messenger.tell(sender, "Could not find the spawnpoint " + args[0] + "for the arena '" + am.getSelectedArena().configName() + "'");
}
if (am.getSelectedArena().getRegion().removeSpawn(arg1))
Messenger.tell(sender, "Spawnpoint " + arg1 + " removed for arena '" + am.getSelectedArena().configName() + "'");
else
Messenger.tell(sender, "Could not find the spawnpoint " + arg1 + "for the arena '" + am.getSelectedArena().configName() + "'");
return true;
}
}

View File

@ -18,24 +18,16 @@ public class SetArenaCommand implements Command
{
@Override
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
// Require an argument
if (arg1.equals("")) {
Messenger.tell(sender, "Usage: /ma setarena <arena>");
return false;
}
// Require an arena name
if (args.length != 1) return false;
Arena arena = am.getArenaWithName(arg1);
Arena arena = am.getArenaWithName(args[0]);
if (arena != null) {
am.setSelectedArena(arena);
Messenger.tell(sender, "Currently selected arena: " + arena.configName());
}
else {
} else {
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
}
return true;
}
}

View File

@ -21,8 +21,11 @@ public class SetClassCommand implements Command
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
if (!Commands.isPlayer(sender)) {
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
return false;
return true;
}
// Require at least a class name
if (args.length < 1) return false;
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
@ -31,19 +34,9 @@ public class SetClassCommand implements Command
// Cast the sender.
Player p = (Player) sender;
// Require an argument.
if (arg1.equals("")) {
Messenger.tell(p, "Usage: /ma setclass (safe) <classname>");
return true;
}
// Check if we're overwriting.
boolean safe = arg1.equals("safe");
if (safe && arg2.equals("")) {
Messenger.tell(p, "Usage: /ma setclass (safe) <classname>");
return true;
}
if (safe && arg2.equals("")) return false;
// If so, use arg2, otherwise, use arg1
String className = TextUtils.camelCase(safe ? arg2 : arg1);

View File

@ -22,7 +22,7 @@ public class SetLobbyRegionCommand implements Command
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
if (!Commands.isPlayer(sender)) {
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
return false;
return true;
}
// Grab the argument, if any.

View File

@ -22,19 +22,14 @@ public class SetRegionCommand implements Command
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
if (!Commands.isPlayer(sender)) {
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
return false;
return true;
}
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
// Require a region point
if (args.length != 1 || !args[0].matches("p1|p2")) return false;
// Cast the sender.
Player p = (Player) sender;
if (!(arg1.equals("p1") || arg1.equals("p2"))) {
Messenger.tell(sender, "Usage: /ma setregion p1|p2");
return true;
}
Arena arena = am.getSelectedArena();
World aw = arena.getWorld();
@ -46,8 +41,8 @@ public class SetRegionCommand implements Command
}
arena.setWorld(p.getWorld());
arena.getRegion().set(arg1, p.getLocation());
Messenger.tell(sender, "Region point " + arg1 + " for arena '" + am.getSelectedArena().configName() + "' set.");
arena.getRegion().set(args[0], p.getLocation());
Messenger.tell(sender, "Region point " + args[0] + " for arena '" + am.getSelectedArena().configName() + "' set.");
arena.getRegion().checkData(am.getPlugin(), sender, true, true, false, false);
return true;
}

View File

@ -9,9 +9,6 @@ import com.garbagemule.MobArena.*;
import com.garbagemule.MobArena.commands.*;
import com.garbagemule.MobArena.framework.ArenaMaster;
import java.util.Arrays;
import java.util.List;
@CommandInfo(
name = "setwarp",
pattern = "set(warp|point)",
@ -21,26 +18,25 @@ import java.util.List;
)
public class SetWarpCommand implements Command
{
private static final List<String> WARPS = Arrays.asList("arena", "lobby", "spectator", "exit");
@Override
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
if (!Commands.isPlayer(sender)) {
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
return false;
return true;
}
// Grab the argument, if any.
String arg1 = (args.length > 0 ? args[0] : "");
// Require a point name
if (args.length != 1) return false;
// Cast the sender.
Player p = (Player) sender;
// spec -> spectator
if (arg1.equals("spec")) arg1 = "spectator";
if (args[0].equals("spec")) args[0] = "spectator";
if (!WARPS.contains(arg1)) {
Messenger.tell(sender, "Usage: /ma setwarp arena|lobby|spectator|exit");
// Check that the point is valid
if (!args[0].matches("arena|lobby|spectator|exit")) {
Messenger.tell(sender, "There's no warp called '" + args[0] + "'.");
return true;
}
@ -48,13 +44,13 @@ public class SetWarpCommand implements Command
Arena arena = am.getSelectedArena();
World aw = arena.getWorld();
World pw = p.getLocation().getWorld();
boolean changeWorld = !arg1.equals("exit") && !aw.getName().equals(pw.getName());
boolean changeWorld = !args[0].equals("exit") && !aw.getName().equals(pw.getName());
// Change worlds to make sure the region check doesn't fail
if (changeWorld) arena.setWorld(pw);
// Make sure the arena warp is inside the region
if (arg1.equals("arena") && !arena.getRegion().contains(p.getLocation())) {
if (args[0].equals("arena") && !arena.getRegion().contains(p.getLocation())) {
if (arena.getRegion().isDefined()) {
Messenger.tell(sender, "You must be inside the arena region!");
} else {
@ -65,7 +61,7 @@ public class SetWarpCommand implements Command
if (changeWorld) arena.setWorld(aw);
} else {
// Set the region point
arena.getRegion().set(arg1, p.getLocation());
arena.getRegion().set(args[0], p.getLocation());
// Notify the player if world changed
if (changeWorld) {
@ -74,7 +70,7 @@ public class SetWarpCommand implements Command
}
// Then notify about point set
Messenger.tell(sender, "Warp point '" + arg1 + "' was set for arena '" + am.getSelectedArena().configName() + "'");
Messenger.tell(sender, "Warp point '" + args[0] + "' was set for arena '" + am.getSelectedArena().configName() + "'");
arena.getRegion().checkData(am.getPlugin(), sender, true, false, true, false);
}
return true;

View File

@ -12,7 +12,7 @@ import org.bukkit.entity.Player;
@CommandInfo(
name = "showlobbyregion",
pattern = "showlobbyregion",
pattern = "showlobby(region)?",
usage = "/ma showlobbyregion (<arena>)",
desc = "show a lobby region",
permission = "mobarena.setup.showlobbyregion"
@ -23,7 +23,7 @@ public class ShowLobbyRegionCommand implements Command
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
if (!Commands.isPlayer(sender)) {
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
return false;
return true;
}
// Grab the argument, if any.
@ -33,25 +33,22 @@ public class ShowLobbyRegionCommand implements Command
Player p = (Player) sender;
Arena arena;
if (arg1.equals("")) {
arena = am.getArenaAtLocation(p.getLocation());
if (arena == null) {
arena = am.getSelectedArena();
}
}
else {
} else {
arena = am.getArenaWithName(arg1);
if (arena == null) {
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
return false;
return true;
}
}
if (!arena.getRegion().isLobbyDefined()) {
Messenger.tell(sender, "The lobby region is not defined for the selected arena.");
return false;
return true;
}
// Show an error message if we aren't in the right world
@ -59,11 +56,9 @@ public class ShowLobbyRegionCommand implements Command
Messenger.tell(sender, "Arena '" + arena.configName() +
"' is in world '" + arena.getWorld().getName() +
"' and you are in world '" + p.getWorld().getName() + "'");
return false;
return true;
}
arena.getRegion().showLobbyRegion(p);
return true;
}
}

View File

@ -10,7 +10,7 @@ import com.garbagemule.MobArena.framework.ArenaMaster;
@CommandInfo(
name = "showregion",
pattern = "showregion",
pattern = "show(region|arena)",
usage = "/ma showregion (<arena>)",
desc = "show an arena region",
permission = "mobarena.setup.showregion"
@ -21,7 +21,7 @@ public class ShowRegionCommand implements Command
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
if (!Commands.isPlayer(sender)) {
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
return false;
return true;
}
// Grab the argument, if any.
@ -31,25 +31,22 @@ public class ShowRegionCommand implements Command
Player p = (Player) sender;
Arena arena;
if (arg1.equals("")) {
arena = am.getArenaAtLocation(p.getLocation());
if (arena == null) {
arena = am.getSelectedArena();
}
}
else {
} else {
arena = am.getArenaWithName(arg1);
if (arena == null) {
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
return false;
return true;
}
}
if (!arena.getRegion().isDefined()) {
Messenger.tell(sender, "The region is not defined for the selected arena.");
return false;
return true;
}
// Show an error message if we aren't in the right world
@ -57,11 +54,9 @@ public class ShowRegionCommand implements Command
Messenger.tell(sender, "Arena '" + arena.configName() +
"' is in world '" + arena.getWorld().getName() +
"' and you are in world '" + p.getWorld().getName() + "'");
return false;
return true;
}
arena.getRegion().showRegion(p);
return true;
}
}

View File

@ -23,7 +23,7 @@ public class ShowSpawnsCommand implements Command
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
if (!Commands.isPlayer(sender)) {
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
return false;
return true;
}
// Grab the argument, if any.
@ -33,7 +33,6 @@ public class ShowSpawnsCommand implements Command
Player p = (Player) sender;
Arena arena;
if (arg1.equals("")) {
arena = am.getArenaAtLocation(p.getLocation());
if (arena == null) {
@ -42,20 +41,16 @@ public class ShowSpawnsCommand implements Command
if (arena.getRegion().getSpawnpoints().isEmpty()) {
Messenger.tell(sender, "There are no spawnpoints in the selected arena.");
return false;
return true;
}
}
else {
} else {
arena = am.getArenaWithName(arg1);
if (arena == null) {
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
return false;
return true;
}
}
arena.getRegion().showSpawns(p);
return true;
}
}

View File

@ -27,11 +27,9 @@ public class SpawnpointsCommand implements Command
buffy.append(s);
buffy.append(" ");
}
}
else {
} else {
buffy.append(Msg.MISC_NONE);
}
Messenger.tell(sender, "Spawnpoints for arena '" + am.getSelectedArena().configName() + "': " + buffy.toString());
return true;
}

View File

@ -21,7 +21,7 @@ public class JoinCommand implements Command
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
if (!Commands.isPlayer(sender)) {
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
return false;
return true;
}
// Cast the sender, grab the argument, if any.
@ -30,20 +30,20 @@ public class JoinCommand implements Command
// Run some rough sanity checks, and grab the arena to join.
Arena toArena = Commands.getArenaToJoinOrSpec(am, p, arg1);
Arena fromArena = am.getArenaWithPlayer(p);
if (toArena == null) {
return false;
return true;
}
// Deny joining from other arenas
Arena fromArena = am.getArenaWithPlayer(p);
if (fromArena != null && (fromArena.inArena(p) || fromArena.inLobby(p))) {
Messenger.tell(p, Msg.JOIN_ALREADY_PLAYING);
return false;
return true;
}
// Per-arena sanity checks
if (!toArena.canJoin(p)) {
return false;
return true;
}
// Force leave previous arena

View File

@ -21,7 +21,7 @@ public class LeaveCommand implements Command
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
if (!Commands.isPlayer(sender)) {
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
return false;
return true;
}
// Cast the sender.
@ -32,7 +32,7 @@ public class LeaveCommand implements Command
arena = am.getArenaWithSpectator(p);
if (arena == null) {
Messenger.tell(p, Msg.LEAVE_NOT_PLAYING);
return false;
return true;
}
}

View File

@ -31,18 +31,15 @@ public class NotReadyCommand implements Command
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
return false;
}
}
else if (Commands.isPlayer(sender)) {
} else if (Commands.isPlayer(sender)) {
Player p = (Player) sender;
arena = am.getArenaWithPlayer(p);
if (arena == null) {
Messenger.tell(sender, Msg.LEAVE_NOT_PLAYING);
return false;
return true;
}
}
else {
Messenger.tell(sender, "Usage: /ma notready <arena name>");
} else {
return false;
}

View File

@ -35,9 +35,8 @@ public class PlayerListCommand implements Command
}
list = MAUtils.listToString(arena.getPlayersInArena(), am.getPlugin());
}
else {
StringBuffer buffy = new StringBuffer();
} else {
StringBuilder buffy = new StringBuilder();
List<Player> players = new LinkedList<Player>();
for (Arena arena : am.getArenas()) {

View File

@ -30,20 +30,20 @@ public class SpecCommand implements Command
// Run some rough sanity checks, and grab the arena to spec.
Arena toArena = Commands.getArenaToJoinOrSpec(am, p, arg1);
Arena fromArena = am.getArenaWithPlayer(p);
if (toArena == null) {
return false;
return true;
}
// Deny spectating from other arenas
Arena fromArena = am.getArenaWithPlayer(p);
if (fromArena != null && (fromArena.inArena(p) || fromArena.inLobby(p))) {
Messenger.tell(p, Msg.SPEC_ALREADY_PLAYING);
return false;
return true;
}
// Per-arena sanity checks
if (!toArena.canSpec(p)) {
return false;
return true;
}
// Force leave previous arena