From 508366468a5821fa3c4c21d681acab0773416b1a Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Mon, 10 Feb 2014 14:40:27 -0600 Subject: [PATCH] List all the prisoners in a jail if the jail is provided on /jail list --- .../command/subcommands/JailListCommand.java | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/graywolf336/jail/command/subcommands/JailListCommand.java b/src/main/java/com/graywolf336/jail/command/subcommands/JailListCommand.java index a53c597..c671f86 100644 --- a/src/main/java/com/graywolf336/jail/command/subcommands/JailListCommand.java +++ b/src/main/java/com/graywolf336/jail/command/subcommands/JailListCommand.java @@ -5,28 +5,47 @@ 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 = 0, + maxArgs = 1, minimumArgs = 0, needsPlayer = false, pattern = "list|l", permission = "jail.command.jaillist", - usage = "/jail list" + usage = "/jail list " ) public class JailListCommand implements Command { public boolean execute(JailManager jm, CommandSender sender, String... args) { sender.sendMessage(ChatColor.AQUA + "----------Jails----------"); - if(!jm.getJails().isEmpty()) { - for(Jail j : jm.getJails()) { - sender.sendMessage(ChatColor.BLUE + " " + j.getName() + " (" + j.getAllPrisoners().size() + ")"); - } - }else { + //Check if there are any jails + if(jm.getJails().isEmpty()) { sender.sendMessage(" " + jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS)); + }else { + //Check if they have provided a jail to list or not + if(args.length == 1) { + //No jail provided, so give them a list of the jails + for(Jail j : jm.getJails()) { + sender.sendMessage(ChatColor.BLUE + " " + j.getName() + " (" + j.getAllPrisoners().size() + ")"); + } + }else { + Jail j = jm.getJail(args[1]); + + if(j == null) { + //No jail was found + sender.sendMessage(" " + jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAIL, args[1])); + }else { + for(Prisoner p : j.getAllPrisoners()) { + //graywolf663: Being gray's evil twin; CONSOLE (10) + //prisoner: reason; jailer (time in minutes) + sender.sendMessage(ChatColor.BLUE + " " + p.getName() + ": " + p.getReason() + "; " + p.getJailer() + "(" + p.getRemainingTimeInMinutes() + ")"); + } + } + } } sender.sendMessage(ChatColor.AQUA + "-------------------------");