mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-01-23 08:41:19 +01:00
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:
parent
e7d3da4db3
commit
eb04693c3f
@ -8,13 +8,22 @@ public interface Command
|
|||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Execute the command using the given arguments.
|
* Execute the command using the given arguments.
|
||||||
* If any arguments are provided, the first argument is -NOT- the
|
* <p>
|
||||||
* same as the command name, i.e. the CommandHandler must strip the
|
* If the method returns false, the command handler will print the usage
|
||||||
* array of this element.
|
* 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 am an ArenaMaster instance
|
||||||
* @param sender the sender
|
* @param sender the sender
|
||||||
* @param args array of arguments
|
* @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);
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
package com.garbagemule.MobArena.commands;
|
package com.garbagemule.MobArena.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -56,7 +52,7 @@ public class CommandHandler implements CommandExecutor
|
|||||||
if (matches.size() > 1) {
|
if (matches.size() > 1) {
|
||||||
Messenger.tell(sender, Msg.MISC_MULTIPLE_MATCHES);
|
Messenger.tell(sender, Msg.MISC_MULTIPLE_MATCHES);
|
||||||
for (Command cmd : matches) {
|
for (Command cmd : matches) {
|
||||||
showUsage(cmd, sender);
|
showUsage(cmd, sender, false);
|
||||||
}
|
}
|
||||||
return true;
|
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
|
// Check if the last argument is a ?, in which case, display usage and description
|
||||||
if (last.equals("?") || last.equals("help")) {
|
if (last.equals("?") || last.equals("help")) {
|
||||||
showUsage(command, sender);
|
showUsage(command, sender, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, execute the command!
|
// Otherwise, execute the command!
|
||||||
String[] params = trimFirstArg(args);
|
String[] params = trimFirstArg(args);
|
||||||
command.execute(am, sender, params);
|
if (!command.execute(am, sender, params)) {
|
||||||
|
showUsage(command, sender, true);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,11 +111,11 @@ public class CommandHandler implements CommandExecutor
|
|||||||
* @param cmd a Command
|
* @param cmd a Command
|
||||||
* @param sender a CommandSender
|
* @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);
|
CommandInfo info = cmd.getClass().getAnnotation(CommandInfo.class);
|
||||||
if (!plugin.has(sender, info.permission())) return;
|
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
|
* @param sender a player or the console
|
||||||
*/
|
*/
|
||||||
private void showHelp(CommandSender sender) {
|
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()) {
|
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.
|
* method, but this is neater, albeit more manual work.
|
||||||
*/
|
*/
|
||||||
private void registerCommands() {
|
private void registerCommands() {
|
||||||
commands = new HashMap<String,Command>();
|
commands = new LinkedHashMap<String,Command>();
|
||||||
|
|
||||||
// mobarena.use
|
// mobarena.use
|
||||||
register(ArenaListCommand.class);
|
|
||||||
register(JoinCommand.class);
|
register(JoinCommand.class);
|
||||||
register(LeaveCommand.class);
|
register(LeaveCommand.class);
|
||||||
register(NotReadyCommand.class);
|
|
||||||
register(SpecCommand.class);
|
register(SpecCommand.class);
|
||||||
|
register(ArenaListCommand.class);
|
||||||
register(PlayerListCommand.class);
|
register(PlayerListCommand.class);
|
||||||
|
register(NotReadyCommand.class);
|
||||||
|
|
||||||
// mobarena.admin
|
// mobarena.admin
|
||||||
register(DisableCommand.class);
|
|
||||||
register(EnableCommand.class);
|
register(EnableCommand.class);
|
||||||
|
register(DisableCommand.class);
|
||||||
register(ForceCommand.class);
|
register(ForceCommand.class);
|
||||||
register(KickCommand.class);
|
register(KickCommand.class);
|
||||||
register(RestoreCommand.class);
|
register(RestoreCommand.class);
|
||||||
|
|
||||||
// mobarena.setup
|
// 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(ConfigCommand.class);
|
||||||
register(ContainersCommand.class);
|
|
||||||
register(EditArenaCommand.class);
|
register(AddArenaCommand.class);
|
||||||
register(ExpandLobbyRegionCommand.class);
|
|
||||||
register(ExpandRegionCommand.class);
|
|
||||||
register(ListClassesCommand.class);
|
|
||||||
register(ListClassPermsCommand.class);
|
|
||||||
register(ProtectCommand.class);
|
|
||||||
register(RemoveArenaCommand.class);
|
register(RemoveArenaCommand.class);
|
||||||
register(RemoveClassCommand.class);
|
register(EditArenaCommand.class);
|
||||||
register(RemoveClassPermCommand.class);
|
|
||||||
register(RemoveContainerCommand.class);
|
register(ArenaCommand.class);
|
||||||
register(RemoveLeaderboardCommand.class);
|
|
||||||
register(RemoveSpawnpointCommand.class);
|
|
||||||
register(SetArenaCommand.class);
|
register(SetArenaCommand.class);
|
||||||
register(SetClassCommand.class);
|
|
||||||
register(SetLobbyRegionCommand.class);
|
|
||||||
register(SetRegionCommand.class);
|
|
||||||
register(SetWarpCommand.class);
|
register(SetWarpCommand.class);
|
||||||
|
register(SetRegionCommand.class);
|
||||||
|
register(SetLobbyRegionCommand.class);
|
||||||
|
register(ExpandRegionCommand.class);
|
||||||
|
register(ExpandLobbyRegionCommand.class);
|
||||||
register(ShowRegionCommand.class);
|
register(ShowRegionCommand.class);
|
||||||
register(ShowLobbyRegionCommand.class);
|
register(ShowLobbyRegionCommand.class);
|
||||||
|
register(CheckDataCommand.class);
|
||||||
|
|
||||||
register(ShowSpawnsCommand.class);
|
register(ShowSpawnsCommand.class);
|
||||||
register(SpawnpointsCommand.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(AutoGenerateCommand.class);
|
||||||
register(AutoDegenerateCommand.class);
|
register(AutoDegenerateCommand.class);
|
||||||
register(ClassChestCommand.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,9 +33,8 @@ public class DisableCommand implements Command
|
|||||||
Arena arena = am.getArenaWithName(arg1);
|
Arena arena = am.getArenaWithName(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
disable(arena, sender);
|
disable(arena, sender);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -43,7 +42,6 @@ public class DisableCommand implements Command
|
|||||||
am.setEnabled(false);
|
am.setEnabled(false);
|
||||||
am.saveConfig();
|
am.saveConfig();
|
||||||
Messenger.tell(sender, "MobArena " + ChatColor.RED + "disabled");
|
Messenger.tell(sender, "MobArena " + ChatColor.RED + "disabled");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,9 +33,8 @@ public class EnableCommand implements Command
|
|||||||
Arena arena = am.getArenaWithName(arg1);
|
Arena arena = am.getArenaWithName(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
enable(arena, sender);
|
enable(arena, sender);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -43,7 +42,6 @@ public class EnableCommand implements Command
|
|||||||
am.setEnabled(true);
|
am.setEnabled(true);
|
||||||
am.saveConfig();
|
am.saveConfig();
|
||||||
Messenger.tell(sender, "MobArena " + ChatColor.GREEN + "enabled");
|
Messenger.tell(sender, "MobArena " + ChatColor.GREEN + "enabled");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,9 @@ public class ForceCommand implements Command
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
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.
|
// Grab the argument, if any.
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
String arg1 = (args.length > 0 ? args[0] : "");
|
||||||
String arg2 = (args.length > 1 ? args[1] : "");
|
String arg2 = (args.length > 1 ? args[1] : "");
|
||||||
@ -28,7 +31,6 @@ public class ForceCommand implements Command
|
|||||||
for (Arena arena : am.getArenas()) {
|
for (Arena arena : am.getArenas()) {
|
||||||
arena.forceEnd();
|
arena.forceEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger.tell(sender, Msg.FORCE_END_ENDED);
|
Messenger.tell(sender, Msg.FORCE_END_ENDED);
|
||||||
am.resetArenaMap();
|
am.resetArenaMap();
|
||||||
return true;
|
return true;
|
||||||
@ -38,53 +40,46 @@ public class ForceCommand implements Command
|
|||||||
Arena arena = am.getArenaWithName(arg2);
|
Arena arena = am.getArenaWithName(arg2);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arena.getAllPlayers().isEmpty()) {
|
if (arena.getAllPlayers().isEmpty()) {
|
||||||
Messenger.tell(sender, Msg.FORCE_END_EMPTY);
|
Messenger.tell(sender, Msg.FORCE_END_EMPTY);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// And end it!
|
// And end it!
|
||||||
arena.forceEnd();
|
arena.forceEnd();
|
||||||
Messenger.tell(sender, Msg.FORCE_END_ENDED);
|
Messenger.tell(sender, Msg.FORCE_END_ENDED);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg1.equals("start")) {
|
if (arg1.equals("start")) {
|
||||||
// Require argument.
|
// Require argument.
|
||||||
if (arg2.equals("")) {
|
if (arg2.equals("")) return false;
|
||||||
Messenger.tell(sender, "Usage: /ma force start <arena>");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Grab the arena.
|
// Grab the arena.
|
||||||
Arena arena = am.getArenaWithName(arg2);
|
Arena arena = am.getArenaWithName(arg2);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arena.isRunning()) {
|
if (arena.isRunning()) {
|
||||||
Messenger.tell(sender, Msg.FORCE_START_RUNNING);
|
Messenger.tell(sender, Msg.FORCE_START_RUNNING);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arena.getReadyPlayersInLobby().isEmpty()) {
|
if (arena.getReadyPlayersInLobby().isEmpty()) {
|
||||||
Messenger.tell(sender, Msg.FORCE_START_NOT_READY);
|
Messenger.tell(sender, Msg.FORCE_START_NOT_READY);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// And start it!
|
// And start it!
|
||||||
arena.forceStart();
|
arena.forceStart();
|
||||||
Messenger.tell(sender, Msg.FORCE_START_STARTED);
|
Messenger.tell(sender, Msg.FORCE_START_STARTED);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
Messenger.tell(sender, "Usage: /ma force start|end (<arena name>)");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,28 +19,21 @@ public class KickCommand implements Command
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
// Grab the argument, if any.
|
// Require a player name
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 1) return false;
|
||||||
|
|
||||||
// Require an argument
|
Arena arena = am.getArenaWithPlayer(args[0]);
|
||||||
if (arg1.equals("")) {
|
|
||||||
Messenger.tell(sender, "Usage: /ma kick <player>");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Arena arena = am.getArenaWithPlayer(arg1);
|
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tell(sender, "That player is not in an arena.");
|
Messenger.tell(sender, "That player is not in an arena.");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the Player object.
|
// Grab the Player object.
|
||||||
Player bp = am.getPlugin().getServer().getPlayer(arg1);
|
Player bp = am.getPlugin().getServer().getPlayer(args[0]);
|
||||||
|
|
||||||
// Force leave.
|
// Force leave.
|
||||||
arena.playerLeave(bp);
|
arena.playerLeave(bp);
|
||||||
|
Messenger.tell(sender, "Player '" + args[0] + "' was kicked from arena '" + arena.configName() + "'.");
|
||||||
Messenger.tell(sender, "Player '" + arg1 + "' was kicked from arena '" + arena.configName() + "'.");
|
|
||||||
Messenger.tell(bp, "You were kicked by " + sender.getName() + ".");
|
Messenger.tell(bp, "You were kicked by " + sender.getName() + ".");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -18,26 +18,19 @@ public class RestoreCommand implements Command
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
// Grab the argument, if any.
|
// Require a player name
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 1) return false;
|
||||||
|
|
||||||
// Require an argument
|
if (am.getArenaWithPlayer(args[0]) != null) {
|
||||||
if (arg1.equals("")) {
|
|
||||||
Messenger.tell(sender, "Usage: /ma restore <player>");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (am.getArenaWithPlayer(arg1) != null) {
|
|
||||||
Messenger.tell(sender, "Player is currently in an arena.");
|
Messenger.tell(sender, "Player is currently in an arena.");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (InventoryManager.restoreFromFile(am.getPlugin(), am.getPlugin().getServer().getPlayer(arg1))) {
|
if (InventoryManager.restoreFromFile(am.getPlugin(), am.getPlugin().getServer().getPlayer(args[0]))) {
|
||||||
Messenger.tell(sender, "Restored " + arg1 + "'s inventory!");
|
Messenger.tell(sender, "Restored " + args[0] + "'s inventory!");
|
||||||
} else {
|
} else {
|
||||||
Messenger.tell(sender, "Failed to restore " + arg1 + "'s inventory.");
|
Messenger.tell(sender, "Failed to restore " + args[0] + "'s inventory.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,31 +21,25 @@ public class AddArenaCommand implements Command
|
|||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the argument, if any.
|
// Require an arena name
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 1) return false;
|
||||||
|
|
||||||
// Cast the sender.
|
// Cast the sender.
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
|
|
||||||
// Require an argument
|
Arena arena = am.getArenaWithName(args[0]);
|
||||||
if (arg1.equals("")) {
|
|
||||||
Messenger.tell(sender, "Usage: /ma addarena <arena>");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
Arena arena = am.getArenaWithName(arg1);
|
|
||||||
if (arena != null) {
|
if (arena != null) {
|
||||||
Messenger.tell(sender, "An arena with that name already exists.");
|
Messenger.tell(sender, "An arena with that name already exists.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
arena = am.createArenaNode(arg1, p.getWorld());
|
arena = am.createArenaNode(args[0], p.getWorld());
|
||||||
am.setSelectedArena(arena);
|
am.setSelectedArena(arena);
|
||||||
|
|
||||||
Messenger.tell(sender, "New arena with name '" + arg1 + "' created!");
|
Messenger.tell(sender, "New arena with name '" + args[0] + "' created!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,30 +18,24 @@ public class AddClassPermCommand implements Command
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
// Grab the argument, if any.
|
// Require classname and permission
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 2) return false;
|
||||||
String arg2 = (args.length > 1 ? args[1] : "");
|
|
||||||
|
|
||||||
if (arg1.equals("") || arg2.equals("")) {
|
|
||||||
Messenger.tell(sender, "Usage: /ma addclassperm <classname> <permission>");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Grab the arena class
|
// Grab the arena class
|
||||||
ArenaClass arenaClass = am.getClasses().get(arg1);
|
ArenaClass arenaClass = am.getClasses().get(args[0]);
|
||||||
if (arenaClass == null) {
|
if (arenaClass == null) {
|
||||||
Messenger.tell(sender, "The class '" + TextUtils.camelCase(arg1) + "' does not exist.");
|
Messenger.tell(sender, "The class '" + TextUtils.camelCase(args[0]) + "' does not exist.");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to add the permission.
|
// Try to add the permission.
|
||||||
if (am.addClassPermission(arg1, arg2)) {
|
if (am.addClassPermission(args[0], args[1])) {
|
||||||
Messenger.tell(sender, "Added permission '" + arg2 + "' to class '" + TextUtils.camelCase(arg1) + "'.");
|
Messenger.tell(sender, "Added permission '" + args[1] + "' to class '" + TextUtils.camelCase(args[0]) + "'.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it wasn't added, notify.
|
// If it wasn't added, notify.
|
||||||
Messenger.tell(sender, "Permission '" + arg2 + "' was NOT added to class '" + TextUtils.camelCase(arg1) + "'.");
|
Messenger.tell(sender, "Permission '" + args[1] + "' was NOT added to class '" + TextUtils.camelCase(args[0]) + "'.");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,27 +21,23 @@ public class AddContainerCommand implements Command
|
|||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the argument, if any.
|
// Require a point name
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 1 || args[0].matches("^[a-zA-Z][a-zA-Z0-9]*$")) return false;
|
||||||
|
|
||||||
// Cast the sender.
|
// Cast the sender.
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
|
|
||||||
if (!arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$")) {
|
// Make sure we're looking at a container
|
||||||
Messenger.tell(sender, "Usage: /ma addcontainer <point name>");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(p.getTargetBlock(null, 50).getState() instanceof InventoryHolder)) {
|
if (!(p.getTargetBlock(null, 50).getState() instanceof InventoryHolder)) {
|
||||||
Messenger.tell(sender, "You must look at container.");
|
Messenger.tell(sender, "You must look at container.");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
am.getSelectedArena().getRegion().addChest(arg1, p.getTargetBlock(null, 50).getLocation());
|
am.getSelectedArena().getRegion().addChest(args[0], p.getTargetBlock(null, 50).getLocation());
|
||||||
Messenger.tell(sender, "Container '" + arg1 + "' added for arena \"" + am.getSelectedArena().configName() + "\"");
|
Messenger.tell(sender, "Container '" + args[0] + "' added for arena \"" + am.getSelectedArena().configName() + "\"");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,20 +22,15 @@ public class AddSpawnpointCommand implements Command
|
|||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the argument, if any.
|
// Require a point name
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 1 || args[0].matches("^[a-zA-Z][a-zA-Z0-9]*$")) return false;
|
||||||
|
|
||||||
// Cast the sender.
|
// Cast the sender.
|
||||||
Player p = (Player) 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
|
// Make a world check first
|
||||||
Arena arena = am.getSelectedArena();
|
Arena arena = am.getSelectedArena();
|
||||||
World aw = arena.getWorld();
|
World aw = arena.getWorld();
|
||||||
@ -57,7 +52,7 @@ public class AddSpawnpointCommand implements Command
|
|||||||
if (changeWorld) arena.setWorld(aw);
|
if (changeWorld) arena.setWorld(aw);
|
||||||
} else {
|
} else {
|
||||||
// Add the spawnpoint
|
// Add the spawnpoint
|
||||||
am.getSelectedArena().getRegion().addSpawn(arg1, p.getLocation());
|
am.getSelectedArena().getRegion().addSpawn(args[0], p.getLocation());
|
||||||
|
|
||||||
// Notify the player if world changed
|
// Notify the player if world changed
|
||||||
if (changeWorld) {
|
if (changeWorld) {
|
||||||
@ -67,7 +62,7 @@ public class AddSpawnpointCommand implements Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Then notify about point set
|
// 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);
|
arena.getRegion().checkData(am.getPlugin(), sender, false, false, false, true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -18,33 +18,28 @@ public class AutoDegenerateCommand implements Command
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
// Grab the arguments, if any.
|
// Require an arena name
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
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) {
|
if (am.getArenas().size() < 2) {
|
||||||
Messenger.tell(sender, "At least one arena must exist!");
|
Messenger.tell(sender, "At least one arena must exist!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if arena exists.
|
// Check if arena exists.
|
||||||
Arena arena = am.getArenaWithName(arg1);
|
Arena arena = am.getArenaWithName(args[0]);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MAUtils.undoItHippieMonster(arg1, am.getPlugin(), true)) {
|
if (!MAUtils.undoItHippieMonster(args[0], am.getPlugin(), true)) {
|
||||||
Messenger.tell(sender, "Could not degenerate arena.");
|
Messenger.tell(sender, "Could not degenerate arena.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger.tell(sender, "Arena with name '" + arg1 + "' degenerated.");
|
Messenger.tell(sender, "Arena with name '" + args[0] + "' degenerated.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,34 +21,28 @@ public class AutoGenerateCommand implements Command
|
|||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the arguments, if any.
|
// Require an arena name
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 1) return false;
|
||||||
|
|
||||||
// Cast the sender.
|
// Cast the sender.
|
||||||
Player p = (Player) 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.
|
// Check if arena already exists.
|
||||||
Arena arena = am.getArenaWithName(arg1);
|
Arena arena = am.getArenaWithName(args[0]);
|
||||||
if (arena != null) {
|
if (arena != null) {
|
||||||
Messenger.tell(sender, "An arena with that name already exists.");
|
Messenger.tell(sender, "An arena with that name already exists.");
|
||||||
return true;
|
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.");
|
Messenger.tell(sender, "Could not auto-generate arena.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger.tell(sender, "Arena with name '" + arg1 + "' generated.");
|
Messenger.tell(sender, "Arena with name '" + args[0] + "' generated.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import com.garbagemule.MobArena.framework.ArenaMaster;
|
|||||||
@CommandInfo(
|
@CommandInfo(
|
||||||
name = "checkdata",
|
name = "checkdata",
|
||||||
pattern = "checkdata",
|
pattern = "checkdata",
|
||||||
usage = "/ma checkdata",
|
usage = "/ma checkdata (<arena>)",
|
||||||
desc = "check if all required points are set up",
|
desc = "check if all required points are set up",
|
||||||
permission = "mobarena.setup.checkdata"
|
permission = "mobarena.setup.checkdata"
|
||||||
)
|
)
|
||||||
@ -24,7 +24,7 @@ public class CheckDataCommand implements Command
|
|||||||
Arena arena = arg1.equals("") ? am.getSelectedArena() : am.getArenaWithName(arg1);
|
Arena arena = arg1.equals("") ? am.getSelectedArena() : am.getArenaWithName(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
arena.getRegion().checkData(am.getPlugin(), sender, true, true, true, true);
|
arena.getRegion().checkData(am.getPlugin(), sender, true, true, true, true);
|
||||||
|
@ -23,7 +23,7 @@ public class CheckSpawnsCommand implements Command
|
|||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the argument, if any.
|
// Grab the argument, if any.
|
||||||
@ -33,29 +33,23 @@ public class CheckSpawnsCommand implements Command
|
|||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
|
|
||||||
Arena arena;
|
Arena arena;
|
||||||
|
|
||||||
if (arg1.equals("")) {
|
if (arg1.equals("")) {
|
||||||
arena = am.getArenaAtLocation(p.getLocation());
|
arena = am.getArenaAtLocation(p.getLocation());
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
arena = am.getSelectedArena();
|
arena = am.getSelectedArena();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arena.getRegion().getSpawnpoints().isEmpty()) {
|
if (arena.getRegion().getSpawnpoints().isEmpty()) {
|
||||||
Messenger.tell(sender, "There are no spawnpoints in the selected arena.");
|
Messenger.tell(sender, "There are no spawnpoints in the selected arena.");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
arena = am.getArenaWithName(arg1);
|
arena = am.getArenaWithName(arg1);
|
||||||
|
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
arena.getRegion().checkSpawns(p);
|
arena.getRegion().checkSpawns(p);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,12 @@ public class ClassChestCommand implements Command {
|
|||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.length != 1) {
|
|
||||||
Messenger.tell(sender, "Usage: /ma classchest <class>");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Require a class name
|
||||||
|
if (args.length != 1) return false;
|
||||||
|
|
||||||
ArenaClass ac = am.getClasses().get(args[0].toLowerCase());
|
ArenaClass ac = am.getClasses().get(args[0].toLowerCase());
|
||||||
if (ac == null) {
|
if (ac == null) {
|
||||||
Messenger.tell(sender, "Class not found.");
|
Messenger.tell(sender, "Class not found.");
|
||||||
|
@ -17,23 +17,18 @@ public class ConfigCommand implements Command
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
// Grab the argument, if any.
|
// Require reload/save
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 1) return false;
|
||||||
|
|
||||||
if (arg1.equals("reload")) {
|
if (args[0].equals("reload")) {
|
||||||
am.reloadConfig();
|
am.reloadConfig();
|
||||||
Messenger.tell(sender, "Config reloaded.");
|
Messenger.tell(sender, "Config reloaded.");
|
||||||
return true;
|
} else if (args[0].equals("save")) {
|
||||||
}
|
|
||||||
|
|
||||||
if (arg1.equals("save")) {
|
|
||||||
am.saveConfig();
|
am.saveConfig();
|
||||||
Messenger.tell(sender, "Config saved.");
|
Messenger.tell(sender, "Config saved.");
|
||||||
return true;
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
// Requires an argument.
|
|
||||||
Messenger.tell(sender, "Usage: /ma config reload|save");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,15 +36,13 @@ public class EditArenaCommand implements Command
|
|||||||
// Argument is [true|false]
|
// Argument is [true|false]
|
||||||
if (arg1.matches("true|on") || arg1.matches("false|off")) {
|
if (arg1.matches("true|on") || arg1.matches("false|off")) {
|
||||||
arena = am.getSelectedArena();
|
arena = am.getSelectedArena();
|
||||||
arena.setEditMode(arg1.equals("true"));
|
arena.setEditMode(arg1.matches("true|on"));
|
||||||
}
|
}
|
||||||
// Argument is <arena name>
|
// Argument is <arena name>
|
||||||
else {
|
else {
|
||||||
arena = am.getArenaWithName(arg1);
|
arena = am.getArenaWithName(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tell(sender, "There is no arena with that name.");
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
arena.setEditMode(!arena.inEditMode());
|
arena.setEditMode(!arena.inEditMode());
|
||||||
@ -54,18 +52,14 @@ public class EditArenaCommand implements Command
|
|||||||
// Two arguments
|
// Two arguments
|
||||||
else {
|
else {
|
||||||
if (!(arg2.matches("true|on") || arg2.matches("false|off"))) {
|
if (!(arg2.matches("true|on") || arg2.matches("false|off"))) {
|
||||||
Messenger.tell(sender, "Usage: /ma editarena (true|false)");
|
return false;
|
||||||
Messenger.tell(sender, " or /ma editarena <arena> (true|false)");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
arena = am.getArenaWithName(arg1);
|
arena = am.getArenaWithName(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tell(sender, "There is no arena with that name.");
|
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;
|
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"));
|
Messenger.tell(sender, "Edit mode for arena '" + arena.configName() + "': " + ((arena.inEditMode()) ? ChatColor.GREEN + "true" : ChatColor.RED + "false"));
|
||||||
|
@ -17,40 +17,29 @@ public class ExpandLobbyRegionCommand implements Command
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
// Grab the argument, if any.
|
// Require amount and direction
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 2 || !args[0].matches("(-)?[0-9]+")) return false;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!am.getSelectedArena().getRegion().isLobbyDefined()) {
|
if (!am.getSelectedArena().getRegion().isLobbyDefined()) {
|
||||||
Messenger.tell(sender, "You must first define l1 and l2");
|
Messenger.tell(sender, "You must first define l1 and l2");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg2.equals("up")) {
|
if (args[1].equals("up")) {
|
||||||
am.getSelectedArena().getRegion().expandLobbyUp(Integer.parseInt(arg1));
|
am.getSelectedArena().getRegion().expandLobbyUp(Integer.parseInt(args[0]));
|
||||||
}
|
} else if (args[1].equals("down")) {
|
||||||
else if (arg2.equals("down")) {
|
am.getSelectedArena().getRegion().expandLobbyDown(Integer.parseInt(args[0]));
|
||||||
am.getSelectedArena().getRegion().expandLobbyDown(Integer.parseInt(arg1));
|
} else if (args[1].equals("out")) {
|
||||||
}
|
am.getSelectedArena().getRegion().expandLobbyOut(Integer.parseInt(args[0]));
|
||||||
else if (arg2.equals("out")) {
|
} else {
|
||||||
am.getSelectedArena().getRegion().expandLobbyOut(Integer.parseInt(arg1));
|
return false;
|
||||||
}
|
|
||||||
else {
|
|
||||||
Messenger.tell(sender, "Usage: /ma expandlobbyregion <amount> up|down|out");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case of a "negative" region, fix it!
|
// In case of a "negative" region, fix it!
|
||||||
am.getSelectedArena().getRegion().fixLobbyRegion();
|
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();
|
am.getSelectedArena().getRegion().save();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,40 +17,29 @@ public class ExpandRegionCommand implements Command
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
// Grab the argument, if any.
|
// Require amount and direction
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 2 || !args[0].matches("(-)?[0-9]+")) return false;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!am.getSelectedArena().getRegion().isDefined()) {
|
if (!am.getSelectedArena().getRegion().isDefined()) {
|
||||||
Messenger.tell(sender, "You must first define p1 and p2");
|
Messenger.tell(sender, "You must first define p1 and p2");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg2.equals("up")) {
|
if (args[1].equals("up")) {
|
||||||
am.getSelectedArena().getRegion().expandUp(Integer.parseInt(arg1));
|
am.getSelectedArena().getRegion().expandUp(Integer.parseInt(args[0]));
|
||||||
}
|
} else if (args[1].equals("down")) {
|
||||||
else if (arg2.equals("down")) {
|
am.getSelectedArena().getRegion().expandDown(Integer.parseInt(args[0]));
|
||||||
am.getSelectedArena().getRegion().expandDown(Integer.parseInt(arg1));
|
} else if (args[1].equals("out")) {
|
||||||
}
|
am.getSelectedArena().getRegion().expandOut(Integer.parseInt(args[0]));
|
||||||
else if (arg2.equals("out")) {
|
} else {
|
||||||
am.getSelectedArena().getRegion().expandOut(Integer.parseInt(arg1));
|
return false;
|
||||||
}
|
|
||||||
else {
|
|
||||||
Messenger.tell(sender, "Usage: /ma expandregion <amount> up|down|out");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case of a "negative" region, fix it!
|
// In case of a "negative" region, fix it!
|
||||||
am.getSelectedArena().getRegion().fixRegion();
|
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();
|
am.getSelectedArena().getRegion().save();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,17 +21,11 @@ public class ListClassPermsCommand implements Command
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
// Grab the argument, if any.
|
// Require a class name
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 1) return false;
|
||||||
|
|
||||||
// Require an argument.
|
ArenaClass arenaClass = am.getClasses().get(args[0]);
|
||||||
if (arg1.equals("")) {
|
String className = TextUtils.camelCase(args[0]);
|
||||||
Messenger.tell(sender, "Usage: /ma listclassperms <classname>");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ArenaClass arenaClass = am.getClasses().get(arg1);
|
|
||||||
String className = TextUtils.camelCase(arg1);
|
|
||||||
|
|
||||||
if (arenaClass == null) {
|
if (arenaClass == null) {
|
||||||
Messenger.tell(sender, "The class '" + className + "' does not exist.");
|
Messenger.tell(sender, "The class '" + className + "' does not exist.");
|
||||||
|
@ -43,8 +43,6 @@ public class ProtectCommand implements Command
|
|||||||
arena = am.getArenaWithName(arg1);
|
arena = am.getArenaWithName(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tell(sender, "There is no arena with that name.");
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
arena.setProtected(!arena.isProtected());
|
arena.setProtected(!arena.isProtected());
|
||||||
@ -54,18 +52,14 @@ public class ProtectCommand implements Command
|
|||||||
// Two arguments
|
// Two arguments
|
||||||
else {
|
else {
|
||||||
if (!(arg2.matches("true|on") || arg2.matches("false|off"))) {
|
if (!(arg2.matches("true|on") || arg2.matches("false|off"))) {
|
||||||
Messenger.tell(sender, "Usage: /ma protect (true|false)");
|
return false;
|
||||||
Messenger.tell(sender, " or /ma protect <arena name> (true|false)");
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
arena = am.getArenaWithName(arg1);
|
arena = am.getArenaWithName(arg1);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tell(sender, "There is no arena with that name.");
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
arena.setProtected(arg2.equals("true"));
|
arena.setProtected(arg2.matches("true|on"));
|
||||||
}
|
}
|
||||||
|
|
||||||
arena.getPlugin().saveConfig();
|
arena.getPlugin().saveConfig();
|
||||||
|
@ -18,24 +18,18 @@ public class RemoveArenaCommand implements Command
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
// Grab the argument, if any.
|
// Require an arena name
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 1) return false;
|
||||||
|
|
||||||
// Require an argument
|
|
||||||
if (arg1.equals("")) {
|
|
||||||
Messenger.tell(sender, "Usage: /ma removearena <arena>");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (am.getArenas().size() == 1) {
|
if (am.getArenas().size() == 1) {
|
||||||
Messenger.tell(sender, "At least one arena must exist.");
|
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) {
|
if (arena == null) {
|
||||||
Messenger.tell(sender, "There is no arena with that name.");
|
Messenger.tell(sender, "There is no arena with that name.");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
am.removeArenaNode(arena);
|
am.removeArenaNode(arena);
|
||||||
|
@ -18,21 +18,15 @@ public class RemoveClassCommand implements Command
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
// Grab the argument, if any.
|
// Require a class name
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 1) return false;
|
||||||
|
|
||||||
// Require an argument.
|
|
||||||
if (arg1.equals("")) {
|
|
||||||
Messenger.tell(sender, "Usage: /ma removeclass <classname>");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the class
|
// Find the class
|
||||||
ArenaClass arenaClass = am.getClasses().get(arg1);
|
ArenaClass arenaClass = am.getClasses().get(args[0]);
|
||||||
String className = TextUtils.camelCase(arg1);
|
String className = TextUtils.camelCase(args[0]);
|
||||||
if (arenaClass == null) {
|
if (arenaClass == null) {
|
||||||
Messenger.tell(sender, "The class '" + className + "' does not exist.");
|
Messenger.tell(sender, "The class '" + className + "' does not exist.");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
am.removeClassNode(className);
|
am.removeClassNode(className);
|
||||||
|
@ -18,30 +18,24 @@ public class RemoveClassPermCommand implements Command
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
// Grab the argument, if any.
|
// Require class name and permission
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 2) return false;
|
||||||
String arg2 = (args.length > 1 ? args[1] : "");
|
|
||||||
|
|
||||||
if (arg1.equals("") || arg2.equals("")) {
|
|
||||||
Messenger.tell(sender, "Usage: /ma removeclassperm <classname> <permission>");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Grab the arena class
|
// Grab the arena class
|
||||||
ArenaClass arenaClass = am.getClasses().get(arg1);
|
ArenaClass arenaClass = am.getClasses().get(args[0]);
|
||||||
if (arenaClass == null) {
|
if (arenaClass == null) {
|
||||||
Messenger.tell(sender, "The class '" + TextUtils.camelCase(arg1) + "' does not exist.");
|
Messenger.tell(sender, "The class '" + TextUtils.camelCase(args[0]) + "' does not exist.");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the permission.
|
// Remove the permission.
|
||||||
if (am.removeClassPermission(arg1, arg2)) {
|
if (am.removeClassPermission(args[0], args[1])) {
|
||||||
Messenger.tell(sender, "Removed permission '" + arg2 + "' from class '" + TextUtils.camelCase(arg1) + "'.");
|
Messenger.tell(sender, "Removed permission '" + args[1] + "' from class '" + TextUtils.camelCase(args[0]) + "'.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it wasn't removed, notify.
|
// If it wasn't removed, notify.
|
||||||
Messenger.tell(sender, "Permission '" + arg2 + "' was NOT removed from class '" + TextUtils.camelCase(arg1) + "'.");
|
Messenger.tell(sender, "Permission '" + args[1] + "' was NOT removed from class '" + TextUtils.camelCase(args[0]) + "'.");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,19 +17,14 @@ public class RemoveContainerCommand implements Command
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
// Grab the argument, if any.
|
// Require a point name
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 1 || !args[0].matches("^[a-zA-Z][a-zA-Z0-9]*$")) return false;
|
||||||
|
|
||||||
// Require an argument
|
if (am.getSelectedArena().getRegion().removeChest(args[0])) {
|
||||||
if (!arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$")) {
|
Messenger.tell(sender, "Container " + args[0] + " removed for arena '" + am.getSelectedArena().configName() + "'");
|
||||||
Messenger.tell(sender, "Usage: /ma removecontainer <point name>");
|
} else {
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,14 +9,14 @@ import com.garbagemule.MobArena.commands.CommandInfo;
|
|||||||
import com.garbagemule.MobArena.framework.ArenaMaster;
|
import com.garbagemule.MobArena.framework.ArenaMaster;
|
||||||
|
|
||||||
@CommandInfo(
|
@CommandInfo(
|
||||||
name = "removeleaderboard",
|
name = "removeleaderboard",
|
||||||
pattern = "(del(.)*|r(e)?m(ove)?)leaderboard",
|
pattern = "(del(.)*|r(e)?m(ove)?)leaderboard",
|
||||||
usage = "/ma removeleaderboard <arenaname>",
|
usage = "/ma removeleaderboard (<arena>)",
|
||||||
desc = "remove the selected arena's leaderboard",
|
desc = "remove the selected arena's leaderboard",
|
||||||
permission = "mobarena.setup.leaderboards"
|
permission = "mobarena.setup.leaderboards"
|
||||||
)
|
)
|
||||||
public class RemoveLeaderboardCommand implements Command{
|
public class RemoveLeaderboardCommand implements Command
|
||||||
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
// Grab the argument, if any.
|
// Grab the argument, if any.
|
||||||
@ -28,29 +28,22 @@ public class RemoveLeaderboardCommand implements Command{
|
|||||||
am.getSelectedArena().getRegion().set("leaderboard", null);
|
am.getSelectedArena().getRegion().set("leaderboard", null);
|
||||||
Messenger.tell(sender, "Leaderboard for " + am.getSelectedArena().arenaName() + " successfully removed!");
|
Messenger.tell(sender, "Leaderboard for " + am.getSelectedArena().arenaName() + " successfully removed!");
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Messenger.tell(sender, Msg.ARENA_LBOARD_NOT_FOUND);
|
Messenger.tell(sender, Msg.ARENA_LBOARD_NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (am.getArenaWithName(arg1) != null) {
|
if (am.getArenaWithName(arg1) != null) {
|
||||||
if (am.getSelectedArena().getRegion().getLeaderboard() != null) {
|
if (am.getSelectedArena().getRegion().getLeaderboard() != null) {
|
||||||
am.getArenaWithName(arg1).getRegion().set("leaderboard", null);
|
am.getArenaWithName(arg1).getRegion().set("leaderboard", null);
|
||||||
Messenger.tell(sender, "Leaderboard for " + am.getArenaWithName(arg1).arenaName() + " successfully removed!");
|
Messenger.tell(sender, "Leaderboard for " + am.getArenaWithName(arg1).arenaName() + " successfully removed!");
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Messenger.tell(sender, Msg.ARENA_LBOARD_NOT_FOUND);
|
Messenger.tell(sender, Msg.ARENA_LBOARD_NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
Messenger.tell(sender, "No arena with that name exists.");
|
||||||
Messenger.tell(sender, "Usage: /ma removeleaderboard <arenaname>");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -17,19 +17,14 @@ public class RemoveSpawnpointCommand implements Command
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
// Grab the argument, if any.
|
// Require a point name
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 1 || !args[0].matches("^[a-zA-Z][a-zA-Z0-9]*$")) return false;
|
||||||
|
|
||||||
// Require an argument
|
if (am.getSelectedArena().getRegion().removeSpawn(args[0])) {
|
||||||
if (!arg1.matches("^[a-zA-Z][a-zA-Z0-9]*$")) {
|
Messenger.tell(sender, "Spawnpoint " + args[0] + " removed for arena '" + am.getSelectedArena().configName() + "'");
|
||||||
Messenger.tell(sender, "Usage: /ma removespawn <point name>");
|
} else {
|
||||||
return true;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,24 +18,16 @@ public class SetArenaCommand implements Command
|
|||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
// Grab the argument, if any.
|
// Require an arena name
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 1) return false;
|
||||||
|
|
||||||
// Require an argument
|
Arena arena = am.getArenaWithName(args[0]);
|
||||||
if (arg1.equals("")) {
|
|
||||||
Messenger.tell(sender, "Usage: /ma setarena <arena>");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Arena arena = am.getArenaWithName(arg1);
|
|
||||||
if (arena != null) {
|
if (arena != null) {
|
||||||
am.setSelectedArena(arena);
|
am.setSelectedArena(arena);
|
||||||
Messenger.tell(sender, "Currently selected arena: " + arena.configName());
|
Messenger.tell(sender, "Currently selected arena: " + arena.configName());
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,12 @@ public class SetClassCommand implements Command
|
|||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
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.
|
// Grab the argument, if any.
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
String arg1 = (args.length > 0 ? args[0] : "");
|
||||||
String arg2 = (args.length > 1 ? args[1] : "");
|
String arg2 = (args.length > 1 ? args[1] : "");
|
||||||
@ -31,19 +34,9 @@ public class SetClassCommand implements Command
|
|||||||
// Cast the sender.
|
// Cast the sender.
|
||||||
Player p = (Player) 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.
|
// Check if we're overwriting.
|
||||||
boolean safe = arg1.equals("safe");
|
boolean safe = arg1.equals("safe");
|
||||||
|
if (safe && arg2.equals("")) return false;
|
||||||
if (safe && arg2.equals("")) {
|
|
||||||
Messenger.tell(p, "Usage: /ma setclass (safe) <classname>");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If so, use arg2, otherwise, use arg1
|
// If so, use arg2, otherwise, use arg1
|
||||||
String className = TextUtils.camelCase(safe ? arg2 : arg1);
|
String className = TextUtils.camelCase(safe ? arg2 : arg1);
|
||||||
|
@ -22,7 +22,7 @@ public class SetLobbyRegionCommand implements Command
|
|||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the argument, if any.
|
// Grab the argument, if any.
|
||||||
|
@ -22,20 +22,15 @@ public class SetRegionCommand implements Command
|
|||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the argument, if any.
|
// Require a region point
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 1 || !args[0].matches("p1|p2")) return false;
|
||||||
|
|
||||||
// Cast the sender.
|
// Cast the sender.
|
||||||
Player p = (Player) 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();
|
Arena arena = am.getSelectedArena();
|
||||||
World aw = arena.getWorld();
|
World aw = arena.getWorld();
|
||||||
World pw = p.getLocation().getWorld();
|
World pw = p.getLocation().getWorld();
|
||||||
@ -46,8 +41,8 @@ public class SetRegionCommand implements Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
arena.setWorld(p.getWorld());
|
arena.setWorld(p.getWorld());
|
||||||
arena.getRegion().set(arg1, p.getLocation());
|
arena.getRegion().set(args[0], p.getLocation());
|
||||||
Messenger.tell(sender, "Region point " + arg1 + " for arena '" + am.getSelectedArena().configName() + "' set.");
|
Messenger.tell(sender, "Region point " + args[0] + " for arena '" + am.getSelectedArena().configName() + "' set.");
|
||||||
arena.getRegion().checkData(am.getPlugin(), sender, true, true, false, false);
|
arena.getRegion().checkData(am.getPlugin(), sender, true, true, false, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -9,9 +9,6 @@ import com.garbagemule.MobArena.*;
|
|||||||
import com.garbagemule.MobArena.commands.*;
|
import com.garbagemule.MobArena.commands.*;
|
||||||
import com.garbagemule.MobArena.framework.ArenaMaster;
|
import com.garbagemule.MobArena.framework.ArenaMaster;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@CommandInfo(
|
@CommandInfo(
|
||||||
name = "setwarp",
|
name = "setwarp",
|
||||||
pattern = "set(warp|point)",
|
pattern = "set(warp|point)",
|
||||||
@ -21,26 +18,25 @@ import java.util.List;
|
|||||||
)
|
)
|
||||||
public class SetWarpCommand implements Command
|
public class SetWarpCommand implements Command
|
||||||
{
|
{
|
||||||
private static final List<String> WARPS = Arrays.asList("arena", "lobby", "spectator", "exit");
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the argument, if any.
|
// Require a point name
|
||||||
String arg1 = (args.length > 0 ? args[0] : "");
|
if (args.length != 1) return false;
|
||||||
|
|
||||||
// Cast the sender.
|
// Cast the sender.
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
|
|
||||||
// spec -> spectator
|
// spec -> spectator
|
||||||
if (arg1.equals("spec")) arg1 = "spectator";
|
if (args[0].equals("spec")) args[0] = "spectator";
|
||||||
|
|
||||||
if (!WARPS.contains(arg1)) {
|
// Check that the point is valid
|
||||||
Messenger.tell(sender, "Usage: /ma setwarp arena|lobby|spectator|exit");
|
if (!args[0].matches("arena|lobby|spectator|exit")) {
|
||||||
|
Messenger.tell(sender, "There's no warp called '" + args[0] + "'.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,13 +44,13 @@ public class SetWarpCommand implements Command
|
|||||||
Arena arena = am.getSelectedArena();
|
Arena arena = am.getSelectedArena();
|
||||||
World aw = arena.getWorld();
|
World aw = arena.getWorld();
|
||||||
World pw = p.getLocation().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
|
// Change worlds to make sure the region check doesn't fail
|
||||||
if (changeWorld) arena.setWorld(pw);
|
if (changeWorld) arena.setWorld(pw);
|
||||||
|
|
||||||
// Make sure the arena warp is inside the region
|
// 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()) {
|
if (arena.getRegion().isDefined()) {
|
||||||
Messenger.tell(sender, "You must be inside the arena region!");
|
Messenger.tell(sender, "You must be inside the arena region!");
|
||||||
} else {
|
} else {
|
||||||
@ -65,7 +61,7 @@ public class SetWarpCommand implements Command
|
|||||||
if (changeWorld) arena.setWorld(aw);
|
if (changeWorld) arena.setWorld(aw);
|
||||||
} else {
|
} else {
|
||||||
// Set the region point
|
// Set the region point
|
||||||
arena.getRegion().set(arg1, p.getLocation());
|
arena.getRegion().set(args[0], p.getLocation());
|
||||||
|
|
||||||
// Notify the player if world changed
|
// Notify the player if world changed
|
||||||
if (changeWorld) {
|
if (changeWorld) {
|
||||||
@ -74,7 +70,7 @@ public class SetWarpCommand implements Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Then notify about point set
|
// 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);
|
arena.getRegion().checkData(am.getPlugin(), sender, true, false, true, false);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -12,7 +12,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
@CommandInfo(
|
@CommandInfo(
|
||||||
name = "showlobbyregion",
|
name = "showlobbyregion",
|
||||||
pattern = "showlobbyregion",
|
pattern = "showlobby(region)?",
|
||||||
usage = "/ma showlobbyregion (<arena>)",
|
usage = "/ma showlobbyregion (<arena>)",
|
||||||
desc = "show a lobby region",
|
desc = "show a lobby region",
|
||||||
permission = "mobarena.setup.showlobbyregion"
|
permission = "mobarena.setup.showlobbyregion"
|
||||||
@ -23,7 +23,7 @@ public class ShowLobbyRegionCommand implements Command
|
|||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the argument, if any.
|
// Grab the argument, if any.
|
||||||
@ -33,25 +33,22 @@ public class ShowLobbyRegionCommand implements Command
|
|||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
|
|
||||||
Arena arena;
|
Arena arena;
|
||||||
|
|
||||||
if (arg1.equals("")) {
|
if (arg1.equals("")) {
|
||||||
arena = am.getArenaAtLocation(p.getLocation());
|
arena = am.getArenaAtLocation(p.getLocation());
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
arena = am.getSelectedArena();
|
arena = am.getSelectedArena();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
arena = am.getArenaWithName(arg1);
|
arena = am.getArenaWithName(arg1);
|
||||||
|
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!arena.getRegion().isLobbyDefined()) {
|
if (!arena.getRegion().isLobbyDefined()) {
|
||||||
Messenger.tell(sender, "The lobby region is not defined for the selected arena.");
|
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
|
// 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() +
|
Messenger.tell(sender, "Arena '" + arena.configName() +
|
||||||
"' is in world '" + arena.getWorld().getName() +
|
"' is in world '" + arena.getWorld().getName() +
|
||||||
"' and you are in world '" + p.getWorld().getName() + "'");
|
"' and you are in world '" + p.getWorld().getName() + "'");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
arena.getRegion().showLobbyRegion(p);
|
arena.getRegion().showLobbyRegion(p);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import com.garbagemule.MobArena.framework.ArenaMaster;
|
|||||||
|
|
||||||
@CommandInfo(
|
@CommandInfo(
|
||||||
name = "showregion",
|
name = "showregion",
|
||||||
pattern = "showregion",
|
pattern = "show(region|arena)",
|
||||||
usage = "/ma showregion (<arena>)",
|
usage = "/ma showregion (<arena>)",
|
||||||
desc = "show an arena region",
|
desc = "show an arena region",
|
||||||
permission = "mobarena.setup.showregion"
|
permission = "mobarena.setup.showregion"
|
||||||
@ -21,7 +21,7 @@ public class ShowRegionCommand implements Command
|
|||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the argument, if any.
|
// Grab the argument, if any.
|
||||||
@ -31,25 +31,22 @@ public class ShowRegionCommand implements Command
|
|||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
|
|
||||||
Arena arena;
|
Arena arena;
|
||||||
|
|
||||||
if (arg1.equals("")) {
|
if (arg1.equals("")) {
|
||||||
arena = am.getArenaAtLocation(p.getLocation());
|
arena = am.getArenaAtLocation(p.getLocation());
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
arena = am.getSelectedArena();
|
arena = am.getSelectedArena();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
arena = am.getArenaWithName(arg1);
|
arena = am.getArenaWithName(arg1);
|
||||||
|
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!arena.getRegion().isDefined()) {
|
if (!arena.getRegion().isDefined()) {
|
||||||
Messenger.tell(sender, "The region is not defined for the selected arena.");
|
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
|
// 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() +
|
Messenger.tell(sender, "Arena '" + arena.configName() +
|
||||||
"' is in world '" + arena.getWorld().getName() +
|
"' is in world '" + arena.getWorld().getName() +
|
||||||
"' and you are in world '" + p.getWorld().getName() + "'");
|
"' and you are in world '" + p.getWorld().getName() + "'");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
arena.getRegion().showRegion(p);
|
arena.getRegion().showRegion(p);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ public class ShowSpawnsCommand implements Command
|
|||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Grab the argument, if any.
|
// Grab the argument, if any.
|
||||||
@ -33,7 +33,6 @@ public class ShowSpawnsCommand implements Command
|
|||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
|
|
||||||
Arena arena;
|
Arena arena;
|
||||||
|
|
||||||
if (arg1.equals("")) {
|
if (arg1.equals("")) {
|
||||||
arena = am.getArenaAtLocation(p.getLocation());
|
arena = am.getArenaAtLocation(p.getLocation());
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
@ -42,20 +41,16 @@ public class ShowSpawnsCommand implements Command
|
|||||||
|
|
||||||
if (arena.getRegion().getSpawnpoints().isEmpty()) {
|
if (arena.getRegion().getSpawnpoints().isEmpty()) {
|
||||||
Messenger.tell(sender, "There are no spawnpoints in the selected arena.");
|
Messenger.tell(sender, "There are no spawnpoints in the selected arena.");
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
arena = am.getArenaWithName(arg1);
|
arena = am.getArenaWithName(arg1);
|
||||||
|
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
arena.getRegion().showSpawns(p);
|
arena.getRegion().showSpawns(p);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,9 @@ public class SpawnpointsCommand implements Command
|
|||||||
buffy.append(s);
|
buffy.append(s);
|
||||||
buffy.append(" ");
|
buffy.append(" ");
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
buffy.append(Msg.MISC_NONE);
|
buffy.append(Msg.MISC_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Messenger.tell(sender, "Spawnpoints for arena '" + am.getSelectedArena().configName() + "': " + buffy.toString());
|
Messenger.tell(sender, "Spawnpoints for arena '" + am.getSelectedArena().configName() + "': " + buffy.toString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ public class JoinCommand implements Command
|
|||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cast the sender, grab the argument, if any.
|
// 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.
|
// Run some rough sanity checks, and grab the arena to join.
|
||||||
Arena toArena = Commands.getArenaToJoinOrSpec(am, p, arg1);
|
Arena toArena = Commands.getArenaToJoinOrSpec(am, p, arg1);
|
||||||
Arena fromArena = am.getArenaWithPlayer(p);
|
|
||||||
if (toArena == null) {
|
if (toArena == null) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deny joining from other arenas
|
// Deny joining from other arenas
|
||||||
|
Arena fromArena = am.getArenaWithPlayer(p);
|
||||||
if (fromArena != null && (fromArena.inArena(p) || fromArena.inLobby(p))) {
|
if (fromArena != null && (fromArena.inArena(p) || fromArena.inLobby(p))) {
|
||||||
Messenger.tell(p, Msg.JOIN_ALREADY_PLAYING);
|
Messenger.tell(p, Msg.JOIN_ALREADY_PLAYING);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Per-arena sanity checks
|
// Per-arena sanity checks
|
||||||
if (!toArena.canJoin(p)) {
|
if (!toArena.canJoin(p)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force leave previous arena
|
// Force leave previous arena
|
||||||
|
@ -21,7 +21,7 @@ public class LeaveCommand implements Command
|
|||||||
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
public boolean execute(ArenaMaster am, CommandSender sender, String... args) {
|
||||||
if (!Commands.isPlayer(sender)) {
|
if (!Commands.isPlayer(sender)) {
|
||||||
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
Messenger.tell(sender, Msg.MISC_NOT_FROM_CONSOLE);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cast the sender.
|
// Cast the sender.
|
||||||
@ -32,7 +32,7 @@ public class LeaveCommand implements Command
|
|||||||
arena = am.getArenaWithSpectator(p);
|
arena = am.getArenaWithSpectator(p);
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tell(p, Msg.LEAVE_NOT_PLAYING);
|
Messenger.tell(p, Msg.LEAVE_NOT_PLAYING);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,18 +31,15 @@ public class NotReadyCommand implements Command
|
|||||||
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
Messenger.tell(sender, Msg.ARENA_DOES_NOT_EXIST);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else if (Commands.isPlayer(sender)) {
|
||||||
else if (Commands.isPlayer(sender)) {
|
|
||||||
Player p = (Player) sender;
|
Player p = (Player) sender;
|
||||||
arena = am.getArenaWithPlayer(p);
|
arena = am.getArenaWithPlayer(p);
|
||||||
|
|
||||||
if (arena == null) {
|
if (arena == null) {
|
||||||
Messenger.tell(sender, Msg.LEAVE_NOT_PLAYING);
|
Messenger.tell(sender, Msg.LEAVE_NOT_PLAYING);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Messenger.tell(sender, "Usage: /ma notready <arena name>");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +35,8 @@ public class PlayerListCommand implements Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
list = MAUtils.listToString(arena.getPlayersInArena(), am.getPlugin());
|
list = MAUtils.listToString(arena.getPlayersInArena(), am.getPlugin());
|
||||||
}
|
} else {
|
||||||
else {
|
StringBuilder buffy = new StringBuilder();
|
||||||
StringBuffer buffy = new StringBuffer();
|
|
||||||
List<Player> players = new LinkedList<Player>();
|
List<Player> players = new LinkedList<Player>();
|
||||||
|
|
||||||
for (Arena arena : am.getArenas()) {
|
for (Arena arena : am.getArenas()) {
|
||||||
|
@ -30,20 +30,20 @@ public class SpecCommand implements Command
|
|||||||
|
|
||||||
// Run some rough sanity checks, and grab the arena to spec.
|
// Run some rough sanity checks, and grab the arena to spec.
|
||||||
Arena toArena = Commands.getArenaToJoinOrSpec(am, p, arg1);
|
Arena toArena = Commands.getArenaToJoinOrSpec(am, p, arg1);
|
||||||
Arena fromArena = am.getArenaWithPlayer(p);
|
|
||||||
if (toArena == null) {
|
if (toArena == null) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Deny spectating from other arenas
|
// Deny spectating from other arenas
|
||||||
|
Arena fromArena = am.getArenaWithPlayer(p);
|
||||||
if (fromArena != null && (fromArena.inArena(p) || fromArena.inLobby(p))) {
|
if (fromArena != null && (fromArena.inArena(p) || fromArena.inLobby(p))) {
|
||||||
Messenger.tell(p, Msg.SPEC_ALREADY_PLAYING);
|
Messenger.tell(p, Msg.SPEC_ALREADY_PLAYING);
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Per-arena sanity checks
|
// Per-arena sanity checks
|
||||||
if (!toArena.canSpec(p)) {
|
if (!toArena.canSpec(p)) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force leave previous arena
|
// Force leave previous arena
|
||||||
|
Loading…
Reference in New Issue
Block a user