Sort the cell list before sending them, adds #80
This commit is contained in:
parent
e92ec67ec9
commit
5393d5556b
@ -1,11 +1,14 @@
|
|||||||
package com.graywolf336.jail.command.subcommands;
|
package com.graywolf336.jail.command.subcommands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
|
import com.graywolf336.jail.Util;
|
||||||
import com.graywolf336.jail.beans.Cell;
|
import com.graywolf336.jail.beans.Cell;
|
||||||
import com.graywolf336.jail.beans.Jail;
|
import com.graywolf336.jail.beans.Jail;
|
||||||
import com.graywolf336.jail.command.Command;
|
import com.graywolf336.jail.command.Command;
|
||||||
@ -21,7 +24,6 @@ import com.graywolf336.jail.enums.Lang;
|
|||||||
usage = "/jail listcells [jail]"
|
usage = "/jail listcells [jail]"
|
||||||
)
|
)
|
||||||
public class JailListCellsCommand implements Command {
|
public class JailListCellsCommand implements Command {
|
||||||
@Override
|
|
||||||
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
public boolean execute(JailManager jm, CommandSender sender, String... args) {
|
||||||
sender.sendMessage(ChatColor.AQUA + "----------Cells----------");
|
sender.sendMessage(ChatColor.AQUA + "----------Cells----------");
|
||||||
|
|
||||||
@ -29,20 +31,15 @@ public class JailListCellsCommand implements Command {
|
|||||||
if(jm.getJail(args[1]) != null) {
|
if(jm.getJail(args[1]) != null) {
|
||||||
Jail j = jm.getJail(args[1]);
|
Jail j = jm.getJail(args[1]);
|
||||||
|
|
||||||
String message = "";
|
List<String> cells = new ArrayList<String>();
|
||||||
|
|
||||||
for(Cell c : j.getCells()) {
|
for(Cell c : j.getCells()) {
|
||||||
if(message.isEmpty()) {
|
cells.add(c.getName() + (c.getPrisoner() == null ? "" : " (" + c.getPrisoner().getLastKnownName() + ")"));
|
||||||
message = c.getName() + (c.getPrisoner() == null ? "" : " (" + c.getPrisoner().getLastKnownName() + ")");
|
|
||||||
}else {
|
|
||||||
message += ", " + c.getName() + (c.getPrisoner() == null ? "" : " (" + c.getPrisoner().getLastKnownName() + ")");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(message.isEmpty()) {
|
Collections.sort(cells);
|
||||||
sender.sendMessage(Lang.NOCELLS.get(j.getName()));
|
|
||||||
}else {
|
sender.sendMessage(cells.size() == 0 ? Lang.NOCELLS.get(j.getName()) : ChatColor.GREEN + Util.getStringFromList(", ", cells));
|
||||||
sender.sendMessage(ChatColor.GREEN + message);
|
|
||||||
}
|
|
||||||
}else {
|
}else {
|
||||||
sender.sendMessage(Lang.NOJAIL.get(args[1]));
|
sender.sendMessage(Lang.NOJAIL.get(args[1]));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user