Move lots of the subcommands to proper place, let's see if this works.

This commit is contained in:
graywolf336 2014-02-01 01:24:44 -06:00
parent 989e503242
commit a088577bee
16 changed files with 171 additions and 64 deletions

View File

@ -10,14 +10,7 @@ import org.bukkit.entity.Player;
import com.graywolf336.jail.JailMain; import com.graywolf336.jail.JailMain;
import com.graywolf336.jail.JailManager; 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.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.UnHandCuffCommand;
import com.graywolf336.jail.command.commands.UnjailCommand; import com.graywolf336.jail.command.commands.UnjailCommand;
import com.graywolf336.jail.enums.LangString; import com.graywolf336.jail.enums.LangString;
@ -143,14 +136,7 @@ public class CommandHandler {
/** Loads all the commands into the hashmap. */ /** Loads all the commands into the hashmap. */
private void loadCommands() { private void loadCommands() {
load(CellCreateCommand.class);
load(HandCuffCommand.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(UnHandCuffCommand.class);
load(UnjailCommand.class); load(UnjailCommand.class);
} }

View File

@ -13,18 +13,32 @@ import com.beust.jcommander.JCommander;
import com.beust.jcommander.ParameterException; import com.beust.jcommander.ParameterException;
import com.graywolf336.jail.JailMain; import com.graywolf336.jail.JailMain;
import com.graywolf336.jail.JailManager; 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.JailFoundation;
import com.graywolf336.jail.command.jcommands.JailList; 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.Mute;
import com.graywolf336.jail.command.jcommands.Reload; 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.Stop;
import com.graywolf336.jail.command.jcommands.TeleIn; import com.graywolf336.jail.command.jcommands.TeleIn;
import com.graywolf336.jail.command.jcommands.TeleOut; import com.graywolf336.jail.command.jcommands.TeleOut;
import com.graywolf336.jail.command.jcommands.Version; 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.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.JailListCommand;
import com.graywolf336.jail.command.subcommands.JailMuteCommand; import com.graywolf336.jail.command.subcommands.JailMuteCommand;
import com.graywolf336.jail.command.subcommands.JailReloadCommand; 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.JailStopCommand;
import com.graywolf336.jail.command.subcommands.JailTeleInCommand; import com.graywolf336.jail.command.subcommands.JailTeleInCommand;
import com.graywolf336.jail.command.subcommands.JailTeleOutCommand; import com.graywolf336.jail.command.subcommands.JailTeleOutCommand;
@ -165,22 +179,41 @@ public class JailHandler {
} }
private void loadCommands() { private void loadCommands() {
load(JailCellCreateCommand.class);
load(JailCheckCommand.class);
load(JailClearCommand.class);
load(JailClearForceCommand.class);
load(JailCommand.class); load(JailCommand.class);
load(JailCreateCommand.class);
load(JailListCellsCommand.class);
load(JailListCommand.class); load(JailListCommand.class);
load(JailMuteCommand.class); load(JailMuteCommand.class);
load(JailReloadCommand.class); load(JailReloadCommand.class);
load(JailRemoveCellCommand.class);
load(JailStopCommand.class); load(JailStopCommand.class);
load(JailTeleInCommand.class); load(JailTeleInCommand.class);
load(JailTeleOutCommand.class); load(JailTeleOutCommand.class);
load(JailVersionCommand.class); load(JailVersionCommand.class);
//Puts the commands in the HashMap //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("list", new JailList());
addCmds.put("l", new JailList()); addCmds.put("l", new JailList());
addCmds.put("listcells", new ListCells());
addCmds.put("lc", new ListCells());
addCmds.put("mute", new Mute()); addCmds.put("mute", new Mute());
addCmds.put("m", new Mute()); addCmds.put("m", new Mute());
addCmds.put("reload", new Reload()); addCmds.put("reload", new Reload());
addCmds.put("r", 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("stop", new Stop());
addCmds.put("s", new Stop()); addCmds.put("s", new Stop());
addCmds.put("telein", new TeleIn()); addCmds.put("telein", new TeleIn());

View File

@ -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<String> parameters = new ArrayList<String>();
}

View File

@ -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<String> parameters = new ArrayList<String>();
}

View File

@ -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<String> parameters = new ArrayList<String>();
}

View File

@ -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<String> parameters = new ArrayList<String>();
}

View File

@ -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<String> parameters = new ArrayList<String>();
}

View File

@ -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<String> parameters = new ArrayList<String>();
}

View File

@ -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<String> parameters = new ArrayList<String>();
}

View File

@ -1,4 +1,4 @@
package com.graywolf336.jail.command.commands; package com.graywolf336.jail.command.subcommands;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -13,21 +13,21 @@ import com.graywolf336.jail.command.CommandInfo;
maxArgs = 2, maxArgs = 2,
minimumArgs = 1, minimumArgs = 1,
needsPlayer = true, needsPlayer = true,
pattern = "jailcreatecells|jcc", pattern = "createcells|cc",
permission = "jail.command.jailcreatecells", permission = "jail.command.jailcreatecells",
usage = "/jail cellcreate [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) { public boolean execute(JailManager jm, CommandSender sender, String... args) {
Player player = (Player) sender; Player player = (Player) sender;
String name = player.getName(); String name = player.getName();
String jail = args[0].toLowerCase(); String jail = args[1].toLowerCase();
String cell = ""; String cell = "";
//Only get the cell name they provide if they provide it //Only get the cell name they provide if they provide it
if(args.length >= 2) { if(args.length >= 3) {
cell = args[1]; cell = args[2];
} }
//Check if the player is currently creating something else //Check if the player is currently creating something else

View File

@ -1,4 +1,4 @@
package com.graywolf336.jail.command.commands; package com.graywolf336.jail.command.subcommands;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -11,24 +11,23 @@ import com.graywolf336.jail.enums.LangString;
maxArgs = 1, maxArgs = 1,
minimumArgs = 0, minimumArgs = 0,
needsPlayer = false, needsPlayer = false,
pattern = "jailcheck|jcheck", pattern = "check",
permission = "jail.command.jailcheck", permission = "jail.command.jailcheck",
usage = "/jail check (Player name)" usage = "/jail check (Player name)"
) )
public class JailCheckCommand implements Command{ public class JailCheckCommand implements Command{
// Checks the status of the specified prisoner, if no args, will display all players currently jailed // 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) { public boolean execute(JailManager jm, CommandSender sender, String... args) {
//No args means show everyone //No args means show everyone
if(args.length == 0) { if(args.length == 1) {
//TODO
}else { }else {
//Otherwise let's check the first arg //Otherwise let's check the first arg
if(jm.isPlayerJailed(args[0])) { if(jm.isPlayerJailed(args[1])) {
//TODO
}else { }else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, args[0])); sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, args[1]));
} }
} }

View File

@ -1,4 +1,4 @@
package com.graywolf336.jail.command.commands; package com.graywolf336.jail.command.subcommands;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -13,7 +13,7 @@ import com.graywolf336.jail.enums.LangString;
maxArgs = 1, maxArgs = 1,
minimumArgs = 0, minimumArgs = 0,
needsPlayer = false, needsPlayer = false,
pattern = "jailclear|jclear", pattern = "clear",
permission = "jail.command.jailclear", permission = "jail.command.jailclear",
usage = "/jail clear (Jail name)" usage = "/jail clear (Jail name)"
) )
@ -21,8 +21,8 @@ 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 // 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) { public boolean execute(JailManager jm, CommandSender sender, String... args) {
if(args.length == 1) { if(args.length == 2) {
Jail j = jm.getJail(args[0]); Jail j = jm.getJail(args[1]);
if(j != null) { if(j != null) {
for(Prisoner p : j.getAllPrisoners()) { for(Prisoner p : j.getAllPrisoners()) {
@ -31,7 +31,7 @@ public class JailClearCommand implements Command {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED, j.getName())); sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED, j.getName()));
}else { }else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[0])); sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1]));
} }
}else { }else {
if(jm.getJails().size() == 0) { if(jm.getJails().size() == 0) {

View File

@ -1,4 +1,4 @@
package com.graywolf336.jail.command.commands; package com.graywolf336.jail.command.subcommands;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -12,7 +12,7 @@ import com.graywolf336.jail.enums.LangString;
maxArgs = 1, maxArgs = 1,
minimumArgs = 0, minimumArgs = 0,
needsPlayer = false, needsPlayer = false,
pattern = "jailclearforce|jcf", pattern = "clearforce|cf",
permission = "jail.command.jailclearforce", permission = "jail.command.jailclearforce",
usage = "/jail clearforce (Jail name)" usage = "/jail clearforce (Jail name)"
) )
@ -20,14 +20,14 @@ public class JailClearForceCommand implements Command {
// If Jail is specified clear all prisoners from that Jail (new feature) else, clear all players from all jails // 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) { public boolean execute(JailManager jm, CommandSender sender, String... args) {
if(args.length == 1) { if(args.length == 2) {
Jail j = jm.getJail(args[0]); Jail j = jm.getJail(args[1]);
if(j != null) { if(j != null) {
j.clearPrisoners(); j.clearPrisoners();
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED, j.getName())); sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED, j.getName()));
}else { }else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[0])); sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1]));
} }
}else { }else {
if(jm.getJails().size() == 0) { if(jm.getJails().size() == 0) {

View File

@ -1,4 +1,4 @@
package com.graywolf336.jail.command.commands; package com.graywolf336.jail.command.subcommands;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -12,7 +12,7 @@ import com.graywolf336.jail.command.CommandInfo;
maxArgs = 1, maxArgs = 1,
minimumArgs = 1, minimumArgs = 1,
needsPlayer = true, needsPlayer = true,
pattern = "jailcreate|jc", pattern = "create",
permission = "jail.command.jailcreate", permission = "jail.command.jailcreate",
usage = "/jail create [name]" usage = "/jail create [name]"
) )
@ -21,7 +21,7 @@ public class JailCreateCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) { public boolean execute(JailManager jm, CommandSender sender, String... args) {
Player player = (Player) sender; Player player = (Player) sender;
String name = player.getName(); String name = player.getName();
String jail = args[0]; String jail = args[1];
//Check if the player is currently creating something else //Check if the player is currently creating something else
if(jm.isCreatingSomething(name)) { if(jm.isCreatingSomething(name)) {

View File

@ -1,4 +1,4 @@
package com.graywolf336.jail.command.commands; package com.graywolf336.jail.command.subcommands;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -14,7 +14,7 @@ import com.graywolf336.jail.enums.LangString;
maxArgs = 1, maxArgs = 1,
minimumArgs = 1, minimumArgs = 1,
needsPlayer = false, needsPlayer = false,
pattern = "jaillistcells|jcc", pattern = "listcells|lc",
permission = "jail.command.jaillistcell", permission = "jail.command.jaillistcell",
usage = "/jail listcells <jail>" usage = "/jail listcells <jail>"
) )
@ -24,8 +24,8 @@ public class JailListCellsCommand implements Command {
sender.sendMessage(ChatColor.AQUA + "----------Cells----------"); sender.sendMessage(ChatColor.AQUA + "----------Cells----------");
if(!jm.getJails().isEmpty()) { if(!jm.getJails().isEmpty()) {
if(jm.getJail(args[0]) != null) { if(jm.getJail(args[1]) != null) {
Jail j = jm.getJail(args[0]); Jail j = jm.getJail(args[1]);
String message = ""; String message = "";
for(Cell c : j.getCells()) { for(Cell c : j.getCells()) {
@ -42,7 +42,7 @@ public class JailListCellsCommand implements Command {
sender.sendMessage(ChatColor.GREEN + message); sender.sendMessage(ChatColor.GREEN + message);
} }
}else { }else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[0])); sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1]));
} }
}else { }else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS)); sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS));

View File

@ -1,4 +1,4 @@
package com.graywolf336.jail.command.commands; package com.graywolf336.jail.command.subcommands;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -12,38 +12,36 @@ import com.graywolf336.jail.enums.LangString;
maxArgs = 2, maxArgs = 2,
minimumArgs = 2, minimumArgs = 2,
needsPlayer = false, needsPlayer = false,
pattern = "jailremovecell|jrcell", pattern = "removecell|rcell|rc",
permission = "jail.command.jailremovecell", permission = "jail.command.jailremovecell",
usage = "/jail removecell [Jail Name] (Cell Name)" usage = "/jail removecell [Jail Name] (Cell Name)"
) )
public class JailRemoveCellCommand implements Command{ public class JailRemoveCellCommand implements Command{
// Remove the specified Cell from the Specified Jail // Remove the specified Cell from the Specified Jail
public boolean execute(JailManager jm, CommandSender sender, String... args) { 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 != null) {
if(!j.getCells().isEmpty()) { if(!j.getCells().isEmpty()) {
if(j.getCell(args[1]) != null) { if(j.getCell(args[2]) != null) {
//remove it! //remove it!
j.removeCell(args[1]); j.removeCell(args[2]);
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CELLREMOVED, sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CELLREMOVED,
new String[] { args[1], args[0] })); new String[] { args[2], args[1] }));
}else { }else {
//No cell by that name //No cell by that name
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOCELL, sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOCELL,
new String[] { args[1], args[0] })); new String[] { args[2], args[1] }));
} }
}else { }else {
//No cells in this jail //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 { }else {
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[0])); sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1]));
} }
return true; return true;
} }
} }