Move lots of the subcommands to proper place, let's see if this works.
This commit is contained in:
parent
989e503242
commit
a088577bee
@ -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);
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -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>();
|
||||
}
|
@ -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>();
|
||||
}
|
@ -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>();
|
||||
}
|
@ -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>();
|
||||
}
|
@ -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>();
|
||||
}
|
@ -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>();
|
||||
}
|
@ -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>();
|
||||
}
|
@ -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
|
@ -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]));
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
@ -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) {
|
@ -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)) {
|
@ -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 <jail>"
|
||||
usage = "/jail listcells <jail>"
|
||||
)
|
||||
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));
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user