Implement the jaillistcell command, prints the prisoner name in the cell

as well if there is someone in there.
This commit is contained in:
graywolf336 2013-12-16 13:57:17 -06:00
parent 7b75c7a158
commit 5febe47880
2 changed files with 52 additions and 0 deletions

View File

@ -10,11 +10,13 @@ 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.CellCreateCommand;
import com.graywolf336.jail.command.commands.JailCheckCommand; import com.graywolf336.jail.command.commands.JailCheckCommand;
import com.graywolf336.jail.command.commands.JailClearCommand; import com.graywolf336.jail.command.commands.JailClearCommand;
import com.graywolf336.jail.command.commands.JailCommand; import com.graywolf336.jail.command.commands.JailCommand;
import com.graywolf336.jail.command.commands.JailCreateCommand; import com.graywolf336.jail.command.commands.JailCreateCommand;
import com.graywolf336.jail.command.commands.JailListCellCommand;
import com.graywolf336.jail.command.commands.JailListCommand; import com.graywolf336.jail.command.commands.JailListCommand;
import com.graywolf336.jail.command.commands.JailRemoveCellCommand; import com.graywolf336.jail.command.commands.JailRemoveCellCommand;
import com.graywolf336.jail.command.commands.JailStopCommand; import com.graywolf336.jail.command.commands.JailStopCommand;
@ -140,6 +142,7 @@ public class CommandHandler {
load(JailClearCommand.class); load(JailClearCommand.class);
load(JailCommand.class); load(JailCommand.class);
load(JailCreateCommand.class); load(JailCreateCommand.class);
load(JailListCellCommand.class);
load(JailListCommand.class); load(JailListCommand.class);
load(JailRemoveCellCommand.class); load(JailRemoveCellCommand.class);
load(JailStopCommand.class); load(JailStopCommand.class);

View File

@ -0,0 +1,49 @@
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;
@CommandInfo(
maxArgs = 1,
minimumArgs = 1,
needsPlayer = false,
pattern = "jaillistcell|jcc",
permission = "jail.command.jaillistcell",
usage = "/jaillistcell <jail>"
)
public class JailListCellCommand implements Command {
@Override
public boolean execute(JailManager jm, CommandSender sender, String... args) {
sender.sendMessage(ChatColor.AQUA + "----------Jails----------");
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() + ")");
}
}
sender.sendMessage(ChatColor.GREEN + message);
}else {
sender.sendMessage(ChatColor.RED + "No jail by the name of '" + args[0] + "'.");
}
}else {
sender.sendMessage(ChatColor.RED + " There are no jails.");
}
sender.sendMessage(ChatColor.AQUA + "-------------------------");
return true;
}
}