List all the prisoners in a jail if the jail is provided on /jail list

This commit is contained in:
graywolf336 2014-02-10 14:40:27 -06:00
parent 05695ce969
commit 508366468a

View File

@ -5,28 +5,47 @@ import org.bukkit.command.CommandSender;
import com.graywolf336.jail.JailManager; import com.graywolf336.jail.JailManager;
import com.graywolf336.jail.beans.Jail; import com.graywolf336.jail.beans.Jail;
import com.graywolf336.jail.beans.Prisoner;
import com.graywolf336.jail.command.Command; import com.graywolf336.jail.command.Command;
import com.graywolf336.jail.command.CommandInfo; import com.graywolf336.jail.command.CommandInfo;
import com.graywolf336.jail.enums.LangString; import com.graywolf336.jail.enums.LangString;
@CommandInfo( @CommandInfo(
maxArgs = 0, maxArgs = 1,
minimumArgs = 0, minimumArgs = 0,
needsPlayer = false, needsPlayer = false,
pattern = "list|l", pattern = "list|l",
permission = "jail.command.jaillist", permission = "jail.command.jaillist",
usage = "/jail list" usage = "/jail list <jail>"
) )
public class JailListCommand implements Command { public class JailListCommand implements Command {
public boolean execute(JailManager jm, CommandSender sender, String... args) { public boolean execute(JailManager jm, CommandSender sender, String... args) {
sender.sendMessage(ChatColor.AQUA + "----------Jails----------"); sender.sendMessage(ChatColor.AQUA + "----------Jails----------");
if(!jm.getJails().isEmpty()) { //Check if there are any jails
for(Jail j : jm.getJails()) { if(jm.getJails().isEmpty()) {
sender.sendMessage(ChatColor.BLUE + " " + j.getName() + " (" + j.getAllPrisoners().size() + ")");
}
}else {
sender.sendMessage(" " + jm.getPlugin().getJailIO().getLanguageString(LangString.NOJAILS)); 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 + "-------------------------"); sender.sendMessage(ChatColor.AQUA + "-------------------------");