Add the jailstop, jailtelein, and jailteleout to subcommands.

This commit is contained in:
graywolf336 2014-01-30 14:10:51 -06:00
parent edb563a9ec
commit 1e632017c7
8 changed files with 78 additions and 20 deletions

View File

@ -18,9 +18,6 @@ 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.JailStopCommand;
import com.graywolf336.jail.command.commands.JailTeleInCommand;
import com.graywolf336.jail.command.commands.JailTeleOutCommand;
import com.graywolf336.jail.command.commands.UnHandCuffCommand;
import com.graywolf336.jail.command.commands.UnjailCommand;
import com.graywolf336.jail.enums.LangString;
@ -154,9 +151,6 @@ public class CommandHandler {
load(JailCreateCommand.class);
load(JailListCellsCommand.class);
load(JailRemoveCellCommand.class);
load(JailStopCommand.class);
load(JailTeleInCommand.class);
load(JailTeleOutCommand.class);
load(UnHandCuffCommand.class);
load(UnjailCommand.class);
}

View File

@ -1,6 +1,7 @@
package com.graywolf336.jail.command;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
@ -16,19 +17,27 @@ import com.graywolf336.jail.command.jcommands.JailFoundation;
import com.graywolf336.jail.command.jcommands.JailList;
import com.graywolf336.jail.command.jcommands.Mute;
import com.graywolf336.jail.command.jcommands.Reload;
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.JailCommand;
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.JailStopCommand;
import com.graywolf336.jail.command.subcommands.JailTeleInCommand;
import com.graywolf336.jail.command.subcommands.JailTeleOutCommand;
import com.graywolf336.jail.command.subcommands.JailVersionCommand;
import com.graywolf336.jail.enums.LangString;
public class JailHandler {
private LinkedHashMap<String, Command> commands;
private HashMap<String, Object> addCmds;
public JailHandler(JailMain plugin) {
commands = new LinkedHashMap<String, Command>();
addCmds = new HashMap<String, Object>();
loadCommands();
plugin.getLogger().info("Loaded " + commands.size() + " sub-commands of /jail.");
@ -41,11 +50,9 @@ public class JailHandler {
JailFoundation foundation = new JailFoundation();
JCommander jc = new JCommander(foundation);
//Now let's add the subcommands
jc.addCommand("list", new JailList());
jc.addCommand("mute", new Mute());
jc.addCommand("reload", new Reload());
jc.addCommand("version", new Version());
for(Entry<String, Object> e : addCmds.entrySet()) {
jc.addCommand(e.getKey(), e.getValue());
}
try {
jc.parse(args);
@ -162,7 +169,25 @@ public class JailHandler {
load(JailListCommand.class);
load(JailMuteCommand.class);
load(JailReloadCommand.class);
load(JailStopCommand.class);
load(JailTeleInCommand.class);
load(JailTeleOutCommand.class);
load(JailVersionCommand.class);
//Puts the commands in the HashMap
addCmds.put("list", new JailList());
addCmds.put("mute", new Mute());
addCmds.put("m", new Mute());
addCmds.put("reload", new Reload());
addCmds.put("r", new Reload());
addCmds.put("stop", new Stop());
addCmds.put("s", new Stop());
addCmds.put("telein", new TeleIn());
addCmds.put("teleportin", new TeleIn());
addCmds.put("teleout", new TeleOut());
addCmds.put("teleportout", new TeleOut());
addCmds.put("version", new Version());
addCmds.put("v", new Version());
}
private void load(Class<? extends Command> c) {

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 = "Stop the creations of anything.")
public class Stop {
@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 = "Teleports a player to the in of jail.")
public class TeleIn {
@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 = "Teleports the player to the teleport out location.")
public class TeleOut {
@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.command.CommandSender;
@ -11,9 +11,9 @@ import com.graywolf336.jail.command.CommandInfo;
maxArgs = 0,
minimumArgs = 0,
needsPlayer = true,
pattern = "jailstop",
pattern = "stop|s",
permission = "jail.command.jailstop",
usage = "/jailstop"
usage = "/jail stop"
)
public class JailStopCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) {

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.entity.Player;
@ -13,9 +13,9 @@ import com.graywolf336.jail.enums.LangString;
maxArgs = 2,
minimumArgs = 1,
needsPlayer = false,
pattern = "jailtelein|jailteleportin",
pattern = "telein|teleportin",
permission = "jail.command.jailtelein",
usage = "/jailtelein <jailname> (player)"
usage = "/jail telein <jailname> (player)"
)
public class JailTeleInCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {

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.entity.Player;
@ -13,9 +13,9 @@ import com.graywolf336.jail.enums.LangString;
maxArgs = 2,
minimumArgs = 1,
needsPlayer = false,
pattern = "jailteleout|jailteleportout",
pattern = "teleout|teleportout",
permission = "jail.command.jailteleout",
usage = "/jailteleout <jailname> (player)"
usage = "/jail teleout <jailname> (player)"
)
public class JailTeleOutCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) throws Exception {