use of com.palmergames.bukkit.towny.object.ResidentList in project Towny by ElgarL.
the class TownyCommand method getMostResidents.
public List<String> getMostResidents(List<ResidentList> list, int maxListing) {
List<String> output = new ArrayList<String>();
KeyValueTable<ResidentList, Integer> kvTable = new KeyValueTable<ResidentList, Integer>();
for (ResidentList obj : list) kvTable.put(obj, obj.getResidents().size());
kvTable.sortByValue();
kvTable.revese();
int n = 0;
for (KeyValue<ResidentList, Integer> kv : kvTable.getKeyValues()) {
n++;
if (maxListing != -1 && n > maxListing)
break;
ResidentList residentList = (ResidentList) kv.key;
output.add(String.format(Colors.Blue + "%30s " + Colors.Gold + "|" + Colors.LightGray + " %10d", TownyFormatter.getFormattedName((TownyObject) residentList), (Integer) kv.value));
}
return output;
}
Aggregations