diff --git a/src/main/java/com/graywolf336/jail/command/CommandHandler.java b/src/main/java/com/graywolf336/jail/command/CommandHandler.java index b6c6bb4..c59e78e 100644 --- a/src/main/java/com/graywolf336/jail/command/CommandHandler.java +++ b/src/main/java/com/graywolf336/jail/command/CommandHandler.java @@ -10,14 +10,7 @@ import org.bukkit.entity.Player; import com.graywolf336.jail.JailMain; import com.graywolf336.jail.JailManager; -import com.graywolf336.jail.command.commands.CellCreateCommand; import com.graywolf336.jail.command.commands.HandCuffCommand; -import com.graywolf336.jail.command.commands.JailCheckCommand; -import com.graywolf336.jail.command.commands.JailClearCommand; -import com.graywolf336.jail.command.commands.JailClearForceCommand; -import com.graywolf336.jail.command.commands.JailCreateCommand; -import com.graywolf336.jail.command.commands.JailListCellsCommand; -import com.graywolf336.jail.command.commands.JailRemoveCellCommand; import com.graywolf336.jail.command.commands.UnHandCuffCommand; import com.graywolf336.jail.command.commands.UnjailCommand; import com.graywolf336.jail.enums.LangString; @@ -143,14 +136,7 @@ public class CommandHandler { /** Loads all the commands into the hashmap. */ private void loadCommands() { - load(CellCreateCommand.class); load(HandCuffCommand.class); - load(JailCheckCommand.class); - load(JailClearCommand.class); - load(JailClearForceCommand.class); - load(JailCreateCommand.class); - load(JailListCellsCommand.class); - load(JailRemoveCellCommand.class); load(UnHandCuffCommand.class); load(UnjailCommand.class); } diff --git a/src/main/java/com/graywolf336/jail/command/JailHandler.java b/src/main/java/com/graywolf336/jail/command/JailHandler.java index c835661..1a6b382 100644 --- a/src/main/java/com/graywolf336/jail/command/JailHandler.java +++ b/src/main/java/com/graywolf336/jail/command/JailHandler.java @@ -13,18 +13,32 @@ import com.beust.jcommander.JCommander; import com.beust.jcommander.ParameterException; import com.graywolf336.jail.JailMain; import com.graywolf336.jail.JailManager; +import com.graywolf336.jail.command.jcommands.CellCreate; +import com.graywolf336.jail.command.jcommands.Check; +import com.graywolf336.jail.command.jcommands.Clear; +import com.graywolf336.jail.command.jcommands.ClearForce; +import com.graywolf336.jail.command.jcommands.Create; import com.graywolf336.jail.command.jcommands.JailFoundation; import com.graywolf336.jail.command.jcommands.JailList; +import com.graywolf336.jail.command.jcommands.ListCells; import com.graywolf336.jail.command.jcommands.Mute; import com.graywolf336.jail.command.jcommands.Reload; +import com.graywolf336.jail.command.jcommands.RemoveCell; import com.graywolf336.jail.command.jcommands.Stop; import com.graywolf336.jail.command.jcommands.TeleIn; import com.graywolf336.jail.command.jcommands.TeleOut; import com.graywolf336.jail.command.jcommands.Version; +import com.graywolf336.jail.command.subcommands.JailCellCreateCommand; +import com.graywolf336.jail.command.subcommands.JailCheckCommand; +import com.graywolf336.jail.command.subcommands.JailClearCommand; +import com.graywolf336.jail.command.subcommands.JailClearForceCommand; import com.graywolf336.jail.command.subcommands.JailCommand; +import com.graywolf336.jail.command.subcommands.JailCreateCommand; +import com.graywolf336.jail.command.subcommands.JailListCellsCommand; import com.graywolf336.jail.command.subcommands.JailListCommand; import com.graywolf336.jail.command.subcommands.JailMuteCommand; import com.graywolf336.jail.command.subcommands.JailReloadCommand; +import com.graywolf336.jail.command.subcommands.JailRemoveCellCommand; import com.graywolf336.jail.command.subcommands.JailStopCommand; import com.graywolf336.jail.command.subcommands.JailTeleInCommand; import com.graywolf336.jail.command.subcommands.JailTeleOutCommand; @@ -165,22 +179,41 @@ public class JailHandler { } private void loadCommands() { + load(JailCellCreateCommand.class); + load(JailCheckCommand.class); + load(JailClearCommand.class); + load(JailClearForceCommand.class); load(JailCommand.class); + load(JailCreateCommand.class); + load(JailListCellsCommand.class); load(JailListCommand.class); load(JailMuteCommand.class); load(JailReloadCommand.class); + load(JailRemoveCellCommand.class); load(JailStopCommand.class); load(JailTeleInCommand.class); load(JailTeleOutCommand.class); load(JailVersionCommand.class); //Puts the commands in the HashMap + addCmds.put("cellcreate", new CellCreate()); + addCmds.put("cc", new CellCreate()); + addCmds.put("check", new Check()); + addCmds.put("clear", new Clear()); + addCmds.put("clearforce", new ClearForce()); + addCmds.put("cf", new ClearForce()); + addCmds.put("create", new Create()); addCmds.put("list", new JailList()); addCmds.put("l", new JailList()); + addCmds.put("listcells", new ListCells()); + addCmds.put("lc", new ListCells()); addCmds.put("mute", new Mute()); addCmds.put("m", new Mute()); addCmds.put("reload", new Reload()); addCmds.put("r", new Reload()); + addCmds.put("removecell", new RemoveCell()); + addCmds.put("rcell", new RemoveCell()); + addCmds.put("rc", new RemoveCell()); addCmds.put("stop", new Stop()); addCmds.put("s", new Stop()); addCmds.put("telein", new TeleIn()); diff --git a/src/main/java/com/graywolf336/jail/command/jcommands/CellCreate.java b/src/main/java/com/graywolf336/jail/command/jcommands/CellCreate.java new file mode 100644 index 0000000..04e157a --- /dev/null +++ b/src/main/java/com/graywolf336/jail/command/jcommands/CellCreate.java @@ -0,0 +1,13 @@ +package com.graywolf336.jail.command.jcommands; + +import java.util.ArrayList; +import java.util.List; + +import com.beust.jcommander.Parameter; +import com.beust.jcommander.Parameters; + +@Parameters(commandDescription = "Starts the creation of cells in the specified jail.") +public class CellCreate { + @Parameter + private List parameters = new ArrayList(); +} diff --git a/src/main/java/com/graywolf336/jail/command/jcommands/Check.java b/src/main/java/com/graywolf336/jail/command/jcommands/Check.java new file mode 100644 index 0000000..99227e4 --- /dev/null +++ b/src/main/java/com/graywolf336/jail/command/jcommands/Check.java @@ -0,0 +1,13 @@ +package com.graywolf336.jail.command.jcommands; + +import java.util.ArrayList; +import java.util.List; + +import com.beust.jcommander.Parameter; +import com.beust.jcommander.Parameters; + +@Parameters(commandDescription = "Checks if a player is jailed and if so gives the sender information about the jailing.") +public class Check { + @Parameter + private List parameters = new ArrayList(); +} diff --git a/src/main/java/com/graywolf336/jail/command/jcommands/Clear.java b/src/main/java/com/graywolf336/jail/command/jcommands/Clear.java new file mode 100644 index 0000000..bd6aa7b --- /dev/null +++ b/src/main/java/com/graywolf336/jail/command/jcommands/Clear.java @@ -0,0 +1,13 @@ +package com.graywolf336.jail.command.jcommands; + +import java.util.ArrayList; +import java.util.List; + +import com.beust.jcommander.Parameter; +import com.beust.jcommander.Parameters; + +@Parameters(commandDescription = "Unjails all the prisoners from all the jails or the specified jail.") +public class Clear { + @Parameter + private List parameters = new ArrayList(); +} diff --git a/src/main/java/com/graywolf336/jail/command/jcommands/ClearForce.java b/src/main/java/com/graywolf336/jail/command/jcommands/ClearForce.java new file mode 100644 index 0000000..5afe014 --- /dev/null +++ b/src/main/java/com/graywolf336/jail/command/jcommands/ClearForce.java @@ -0,0 +1,13 @@ +package com.graywolf336.jail.command.jcommands; + +import java.util.ArrayList; +import java.util.List; + +import com.beust.jcommander.Parameter; +import com.beust.jcommander.Parameters; + +@Parameters(commandDescription = "Starts the creation process of creating a jail.") +public class ClearForce { + @Parameter + private List parameters = new ArrayList(); +} diff --git a/src/main/java/com/graywolf336/jail/command/jcommands/Create.java b/src/main/java/com/graywolf336/jail/command/jcommands/Create.java new file mode 100644 index 0000000..cc3a20d --- /dev/null +++ b/src/main/java/com/graywolf336/jail/command/jcommands/Create.java @@ -0,0 +1,13 @@ +package com.graywolf336.jail.command.jcommands; + +import java.util.ArrayList; +import java.util.List; + +import com.beust.jcommander.Parameter; +import com.beust.jcommander.Parameters; + +@Parameters(commandDescription = "Starts the creation process of creating a jail.") +public class Create { + @Parameter + private List parameters = new ArrayList(); +} diff --git a/src/main/java/com/graywolf336/jail/command/jcommands/ListCells.java b/src/main/java/com/graywolf336/jail/command/jcommands/ListCells.java new file mode 100644 index 0000000..3147cfd --- /dev/null +++ b/src/main/java/com/graywolf336/jail/command/jcommands/ListCells.java @@ -0,0 +1,13 @@ +package com.graywolf336.jail.command.jcommands; + +import java.util.ArrayList; +import java.util.List; + +import com.beust.jcommander.Parameter; +import com.beust.jcommander.Parameters; + +@Parameters(commandDescription = "Lists all the cells in a certain jail.") +public class ListCells { + @Parameter + private List parameters = new ArrayList(); +} diff --git a/src/main/java/com/graywolf336/jail/command/jcommands/RemoveCell.java b/src/main/java/com/graywolf336/jail/command/jcommands/RemoveCell.java new file mode 100644 index 0000000..e87e56a --- /dev/null +++ b/src/main/java/com/graywolf336/jail/command/jcommands/RemoveCell.java @@ -0,0 +1,13 @@ +package com.graywolf336.jail.command.jcommands; + +import java.util.ArrayList; +import java.util.List; + +import com.beust.jcommander.Parameter; +import com.beust.jcommander.Parameters; + +@Parameters(commandDescription = "Removes the cell from the jail.") +public class RemoveCell { + @Parameter + private List parameters = new ArrayList(); +} diff --git a/src/main/java/com/graywolf336/jail/command/commands/CellCreateCommand.java b/src/main/java/com/graywolf336/jail/command/subcommands/JailCellCreateCommand.java similarity index 84% rename from src/main/java/com/graywolf336/jail/command/commands/CellCreateCommand.java rename to src/main/java/com/graywolf336/jail/command/subcommands/JailCellCreateCommand.java index e82eae8..a672020 100644 --- a/src/main/java/com/graywolf336/jail/command/commands/CellCreateCommand.java +++ b/src/main/java/com/graywolf336/jail/command/subcommands/JailCellCreateCommand.java @@ -1,4 +1,4 @@ -package com.graywolf336.jail.command.commands; +package com.graywolf336.jail.command.subcommands; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -13,21 +13,21 @@ import com.graywolf336.jail.command.CommandInfo; maxArgs = 2, minimumArgs = 1, needsPlayer = true, - pattern = "jailcreatecells|jcc", + pattern = "createcells|cc", permission = "jail.command.jailcreatecells", - usage = "/jailcellcreate [jail] (cellname)" + usage = "/jail cellcreate [jail] (cellname)" ) -public class CellCreateCommand implements Command { +public class JailCellCreateCommand implements Command { public boolean execute(JailManager jm, CommandSender sender, String... args) { Player player = (Player) sender; String name = player.getName(); - String jail = args[0].toLowerCase(); + String jail = args[1].toLowerCase(); String cell = ""; //Only get the cell name they provide if they provide it - if(args.length >= 2) { - cell = args[1]; + if(args.length >= 3) { + cell = args[2]; } //Check if the player is currently creating something else diff --git a/src/main/java/com/graywolf336/jail/command/commands/JailCheckCommand.java b/src/main/java/com/graywolf336/jail/command/subcommands/JailCheckCommand.java similarity index 77% rename from src/main/java/com/graywolf336/jail/command/commands/JailCheckCommand.java rename to src/main/java/com/graywolf336/jail/command/subcommands/JailCheckCommand.java index 38d3ae9..dbb3928 100644 --- a/src/main/java/com/graywolf336/jail/command/commands/JailCheckCommand.java +++ b/src/main/java/com/graywolf336/jail/command/subcommands/JailCheckCommand.java @@ -1,4 +1,4 @@ -package com.graywolf336.jail.command.commands; +package com.graywolf336.jail.command.subcommands; import org.bukkit.command.CommandSender; @@ -11,24 +11,23 @@ import com.graywolf336.jail.enums.LangString; maxArgs = 1, minimumArgs = 0, needsPlayer = false, - pattern = "jailcheck|jcheck", + pattern = "check", permission = "jail.command.jailcheck", - usage = "/jailcheck (Player name)" + usage = "/jail check (Player name)" ) public class JailCheckCommand implements Command{ // Checks the status of the specified prisoner, if no args, will display all players currently jailed - public boolean execute(JailManager jm, CommandSender sender, String... args) { //No args means show everyone - if(args.length == 0) { - + if(args.length == 1) { + //TODO }else { //Otherwise let's check the first arg - if(jm.isPlayerJailed(args[0])) { - + if(jm.isPlayerJailed(args[1])) { + //TODO }else { - sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, args[0])); + sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, args[1])); } } diff --git a/src/main/java/com/graywolf336/jail/command/commands/JailClearCommand.java b/src/main/java/com/graywolf336/jail/command/subcommands/JailClearCommand.java similarity index 88% rename from src/main/java/com/graywolf336/jail/command/commands/JailClearCommand.java rename to src/main/java/com/graywolf336/jail/command/subcommands/JailClearCommand.java index 93f85c8..97d2a56 100644 --- a/src/main/java/com/graywolf336/jail/command/commands/JailClearCommand.java +++ b/src/main/java/com/graywolf336/jail/command/subcommands/JailClearCommand.java @@ -1,4 +1,4 @@ -package com.graywolf336.jail.command.commands; +package com.graywolf336.jail.command.subcommands; import org.bukkit.command.CommandSender; @@ -13,16 +13,16 @@ import com.graywolf336.jail.enums.LangString; maxArgs = 1, minimumArgs = 0, needsPlayer = false, - pattern = "jailclear|jclear", + pattern = "clear", permission = "jail.command.jailclear", - usage = "/jailclear (Jail name)" + usage = "/jail clear (Jail name)" ) public class JailClearCommand implements Command { // If Jail is specified unjails all the prisoners from that Jail (new feature) otherwise it unjails all the prisoners from all the jails public boolean execute(JailManager jm, CommandSender sender, String... args) { - if(args.length == 1) { - Jail j = jm.getJail(args[0]); + if(args.length == 2) { + Jail j = jm.getJail(args[1]); if(j != null) { for(Prisoner p : j.getAllPrisoners()) { @@ -31,7 +31,7 @@ public class JailClearCommand implements Command { sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED, j.getName())); }else { - sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[0])); + sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1])); } }else { if(jm.getJails().size() == 0) { diff --git a/src/main/java/com/graywolf336/jail/command/commands/JailClearForceCommand.java b/src/main/java/com/graywolf336/jail/command/subcommands/JailClearForceCommand.java similarity index 86% rename from src/main/java/com/graywolf336/jail/command/commands/JailClearForceCommand.java rename to src/main/java/com/graywolf336/jail/command/subcommands/JailClearForceCommand.java index 01b0ea1..840993b 100644 --- a/src/main/java/com/graywolf336/jail/command/commands/JailClearForceCommand.java +++ b/src/main/java/com/graywolf336/jail/command/subcommands/JailClearForceCommand.java @@ -1,4 +1,4 @@ -package com.graywolf336.jail.command.commands; +package com.graywolf336.jail.command.subcommands; import org.bukkit.command.CommandSender; @@ -12,22 +12,22 @@ import com.graywolf336.jail.enums.LangString; maxArgs = 1, minimumArgs = 0, needsPlayer = false, - pattern = "jailclearforce|jcf", + pattern = "clearforce|cf", permission = "jail.command.jailclearforce", - usage = "/jailclearforce (Jail name)" + usage = "/jail clearforce (Jail name)" ) public class JailClearForceCommand implements Command { // If Jail is specified clear all prisoners from that Jail (new feature) else, clear all players from all jails public boolean execute(JailManager jm, CommandSender sender, String... args) { - if(args.length == 1) { - Jail j = jm.getJail(args[0]); + if(args.length == 2) { + Jail j = jm.getJail(args[1]); if(j != null) { j.clearPrisoners(); sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED, j.getName())); }else { - sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[0])); + sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1])); } }else { if(jm.getJails().size() == 0) { diff --git a/src/main/java/com/graywolf336/jail/command/commands/JailCreateCommand.java b/src/main/java/com/graywolf336/jail/command/subcommands/JailCreateCommand.java similarity index 90% rename from src/main/java/com/graywolf336/jail/command/commands/JailCreateCommand.java rename to src/main/java/com/graywolf336/jail/command/subcommands/JailCreateCommand.java index b31ef3b..5678a8c 100644 --- a/src/main/java/com/graywolf336/jail/command/commands/JailCreateCommand.java +++ b/src/main/java/com/graywolf336/jail/command/subcommands/JailCreateCommand.java @@ -1,4 +1,4 @@ -package com.graywolf336.jail.command.commands; +package com.graywolf336.jail.command.subcommands; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -12,16 +12,16 @@ import com.graywolf336.jail.command.CommandInfo; maxArgs = 1, minimumArgs = 1, needsPlayer = true, - pattern = "jailcreate|jc", + pattern = "create", permission = "jail.command.jailcreate", - usage = "/jailcreate [name]" + usage = "/jail create [name]" ) public class JailCreateCommand implements Command { public boolean execute(JailManager jm, CommandSender sender, String... args) { Player player = (Player) sender; String name = player.getName(); - String jail = args[0]; + String jail = args[1]; //Check if the player is currently creating something else if(jm.isCreatingSomething(name)) { diff --git a/src/main/java/com/graywolf336/jail/command/commands/JailListCellsCommand.java b/src/main/java/com/graywolf336/jail/command/subcommands/JailListCellsCommand.java similarity index 84% rename from src/main/java/com/graywolf336/jail/command/commands/JailListCellsCommand.java rename to src/main/java/com/graywolf336/jail/command/subcommands/JailListCellsCommand.java index f8b862e..a977184 100644 --- a/src/main/java/com/graywolf336/jail/command/commands/JailListCellsCommand.java +++ b/src/main/java/com/graywolf336/jail/command/subcommands/JailListCellsCommand.java @@ -1,4 +1,4 @@ -package com.graywolf336.jail.command.commands; +package com.graywolf336.jail.command.subcommands; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -14,9 +14,9 @@ import com.graywolf336.jail.enums.LangString; maxArgs = 1, minimumArgs = 1, needsPlayer = false, - pattern = "jaillistcells|jcc", + pattern = "listcells|lc", permission = "jail.command.jaillistcell", - usage = "/jaillistcells " + usage = "/jail listcells " ) public class JailListCellsCommand implements Command { @Override @@ -24,8 +24,8 @@ public class JailListCellsCommand implements Command { sender.sendMessage(ChatColor.AQUA + "----------Cells----------"); if(!jm.getJails().isEmpty()) { - if(jm.getJail(args[0]) != null) { - Jail j = jm.getJail(args[0]); + if(jm.getJail(args[1]) != null) { + Jail j = jm.getJail(args[1]); String message = ""; for(Cell c : j.getCells()) { @@ -42,7 +42,7 @@ public class JailListCellsCommand implements Command { sender.sendMessage(ChatColor.GREEN + message); } }else { - sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[0])); + sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1])); } }else { sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS)); diff --git a/src/main/java/com/graywolf336/jail/command/commands/JailRemoveCellCommand.java b/src/main/java/com/graywolf336/jail/command/subcommands/JailRemoveCellCommand.java similarity index 73% rename from src/main/java/com/graywolf336/jail/command/commands/JailRemoveCellCommand.java rename to src/main/java/com/graywolf336/jail/command/subcommands/JailRemoveCellCommand.java index 4f2ba46..fa63b5f 100644 --- a/src/main/java/com/graywolf336/jail/command/commands/JailRemoveCellCommand.java +++ b/src/main/java/com/graywolf336/jail/command/subcommands/JailRemoveCellCommand.java @@ -1,4 +1,4 @@ -package com.graywolf336.jail.command.commands; +package com.graywolf336.jail.command.subcommands; import org.bukkit.command.CommandSender; @@ -12,38 +12,36 @@ import com.graywolf336.jail.enums.LangString; maxArgs = 2, minimumArgs = 2, needsPlayer = false, - pattern = "jailremovecell|jrcell", + pattern = "removecell|rcell|rc", permission = "jail.command.jailremovecell", - usage = "/jailremovecell [Jail Name] (Cell Name)" + usage = "/jail removecell [Jail Name] (Cell Name)" ) public class JailRemoveCellCommand implements Command{ // Remove the specified Cell from the Specified Jail - public boolean execute(JailManager jm, CommandSender sender, String... args) { - Jail j = jm.getJail(args[0]); + Jail j = jm.getJail(args[1]); if(j != null) { if(!j.getCells().isEmpty()) { - if(j.getCell(args[1]) != null) { + if(j.getCell(args[2]) != null) { //remove it! - j.removeCell(args[1]); + j.removeCell(args[2]); sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CELLREMOVED, - new String[] { args[1], args[0] })); + new String[] { args[2], args[1] })); }else { //No cell by that name sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOCELL, - new String[] { args[1], args[0] })); + new String[] { args[2], args[1] })); } }else { //No cells in this jail - sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOCELLS, args[0])); + sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOCELLS, args[1])); } }else { - sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[0])); + sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1])); } return true; } - }