Move lots of the subcommands to proper place, let's see if this works.
This commit is contained in:
@ -1,66 +0,0 @@
|
||||
package com.graywolf336.jail.command.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = true,
|
||||
pattern = "jailcreatecells|jcc",
|
||||
permission = "jail.command.jailcreatecells",
|
||||
usage = "/jailcellcreate [jail] (cellname)"
|
||||
)
|
||||
public class CellCreateCommand 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 cell = "";
|
||||
|
||||
//Only get the cell name they provide if they provide it
|
||||
if(args.length >= 2) {
|
||||
cell = args[1];
|
||||
}
|
||||
|
||||
//Check if the player is currently creating something else
|
||||
if(jm.isCreatingSomething(name)) {
|
||||
String message = jm.getStepMessage(name);
|
||||
if(!message.isEmpty()) {
|
||||
player.sendMessage(ChatColor.RED + message);
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "You're already creating something else, please finish it or cancel.");
|
||||
}
|
||||
}else {
|
||||
//Not creating anything, so let them create some cells.
|
||||
if(jm.isValidJail(jail)) {
|
||||
Jail j = jm.getJail(jail);
|
||||
|
||||
//If they didn't provide a cell name, let's provide one ourself.
|
||||
if(cell.isEmpty()) cell = "cell_n" + (j.getCellCount() + 1);
|
||||
|
||||
if(j.getCell(cell) == null) {
|
||||
if(jm.addCreatingCell(name, jail, cell)) {
|
||||
jm.getCellCreationSteps().startStepping(player);
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "Appears you're creating a cell or something went wrong on our side.");
|
||||
}
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "There's already a cell with the name '" + cell + "', please pick a new one or remove that cell.");
|
||||
}
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "No such jail found by the name of '" + jail + "'.");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
package com.graywolf336.jail.command.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.LangString;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = false,
|
||||
pattern = "jailcheck|jcheck",
|
||||
permission = "jail.command.jailcheck",
|
||||
usage = "/jailcheck (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) {
|
||||
|
||||
}else {
|
||||
//Otherwise let's check the first arg
|
||||
if(jm.isPlayerJailed(args[0])) {
|
||||
|
||||
}else {
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOTJAILED, args[0]));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
package com.graywolf336.jail.command.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.LangString;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = false,
|
||||
pattern = "jailclear|jclear",
|
||||
permission = "jail.command.jailclear",
|
||||
usage = "/jailclear (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(j != null) {
|
||||
for(Prisoner p : j.getAllPrisoners()) {
|
||||
jm.getPlugin().getPrisonerManager().releasePrisoner(jm.getPlugin().getServer().getPlayerExact(p.getName()), p);
|
||||
}
|
||||
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED, j.getName()));
|
||||
}else {
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[0]));
|
||||
}
|
||||
}else {
|
||||
if(jm.getJails().size() == 0) {
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS));
|
||||
}else {
|
||||
for(Jail j : jm.getJails()) {
|
||||
for(Prisoner p : j.getAllPrisoners()) {
|
||||
jm.getPlugin().getPrisonerManager().releasePrisoner(jm.getPlugin().getServer().getPlayerExact(p.getName()), p);
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED,
|
||||
jm.getPlugin().getJailIO().getLanguageString(LangString.ALLJAILS)));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package com.graywolf336.jail.command.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.LangString;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
minimumArgs = 0,
|
||||
needsPlayer = false,
|
||||
pattern = "jailclearforce|jcf",
|
||||
permission = "jail.command.jailclearforce",
|
||||
usage = "/jailclearforce (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(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]));
|
||||
}
|
||||
}else {
|
||||
if(jm.getJails().size() == 0) {
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS));
|
||||
}else {
|
||||
for(Jail j : jm.getJails()) {
|
||||
j.clearPrisoners();
|
||||
}
|
||||
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.PRISONERSCLEARED,
|
||||
jm.getPlugin().getJailIO().getLanguageString(LangString.ALLJAILS)));
|
||||
}
|
||||
}
|
||||
|
||||
return true; //If they made it this far, the command is intact and ready to be processed. :)
|
||||
}
|
||||
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
package com.graywolf336.jail.command.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = true,
|
||||
pattern = "jailcreate|jc",
|
||||
permission = "jail.command.jailcreate",
|
||||
usage = "/jailcreate [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];
|
||||
|
||||
//Check if the player is currently creating something else
|
||||
if(jm.isCreatingSomething(name)) {
|
||||
String message = jm.getStepMessage(name);
|
||||
if(!message.isEmpty()) {
|
||||
player.sendMessage(ChatColor.RED + message);
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "You're already creating something else, please finish it or cancel.");
|
||||
}
|
||||
}else {
|
||||
if(jm.isValidJail(jail)) {
|
||||
player.sendMessage(ChatColor.RED + "Jail by the name of '" + jail + "' already exist!");
|
||||
}else {
|
||||
if(jm.addCreatingJail(name, jail)) {
|
||||
jm.getJailCreationSteps().startStepping(player);
|
||||
}else {
|
||||
player.sendMessage(ChatColor.RED + "Seems like you're already creating a Jail or something went wrong on our side.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
package com.graywolf336.jail.command.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Cell;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.LangString;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 1,
|
||||
minimumArgs = 1,
|
||||
needsPlayer = false,
|
||||
pattern = "jaillistcells|jcc",
|
||||
permission = "jail.command.jaillistcell",
|
||||
usage = "/jaillistcells <jail>"
|
||||
)
|
||||
public class JailListCellsCommand implements Command {
|
||||
@Override
|
||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||
sender.sendMessage(ChatColor.AQUA + "----------Cells----------");
|
||||
|
||||
if(!jm.getJails().isEmpty()) {
|
||||
if(jm.getJail(args[0]) != null) {
|
||||
Jail j = jm.getJail(args[0]);
|
||||
|
||||
String message = "";
|
||||
for(Cell c : j.getCells()) {
|
||||
if(message.isEmpty()) {
|
||||
message = c.getName() + (c.getPrisoner() == null ? "" : "(" + c.getPrisoner().getName() + ")");
|
||||
}else {
|
||||
message += ", " + c.getName() + (c.getPrisoner() == null ? "" : "(" + c.getPrisoner().getName() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if(message.isEmpty()) {
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOCELLS, j.getName()));
|
||||
}else {
|
||||
sender.sendMessage(ChatColor.GREEN + message);
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[0]));
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS));
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.AQUA + "-------------------------");
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package com.graywolf336.jail.command.commands;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.LangString;
|
||||
|
||||
@CommandInfo(
|
||||
maxArgs = 2,
|
||||
minimumArgs = 2,
|
||||
needsPlayer = false,
|
||||
pattern = "jailremovecell|jrcell",
|
||||
permission = "jail.command.jailremovecell",
|
||||
usage = "/jailremovecell [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]);
|
||||
|
||||
if(j != null) {
|
||||
if(!j.getCells().isEmpty()) {
|
||||
if(j.getCell(args[1]) != null) {
|
||||
//remove it!
|
||||
j.removeCell(args[1]);
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.CELLREMOVED,
|
||||
new String[] { args[1], args[0] }));
|
||||
}else {
|
||||
//No cell by that name
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOCELL,
|
||||
new String[] { args[1], args[0] }));
|
||||
}
|
||||
}else {
|
||||
//No cells in this jail
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOCELLS, args[0]));
|
||||
}
|
||||
}else {
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[0]));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user