Search in sources :

Example 1 with TownyEconomyObject

use of com.palmergames.bukkit.towny.object.TownyEconomyObject in project Towny by ElgarL.

the class TownyCommand method getTopBankBalance.

public List<String> getTopBankBalance(List<TownyEconomyObject> list, int maxListing) throws EconomyException {
    List<String> output = new ArrayList<String>();
    KeyValueTable<TownyEconomyObject, Double> kvTable = new KeyValueTable<TownyEconomyObject, Double>();
    for (TownyEconomyObject obj : list) {
        kvTable.put(obj, obj.getHoldingBalance());
    }
    kvTable.sortByValue();
    kvTable.revese();
    int n = 0;
    for (KeyValue<TownyEconomyObject, Double> kv : kvTable.getKeyValues()) {
        n++;
        if (maxListing != -1 && n > maxListing)
            break;
        TownyEconomyObject town = (TownyEconomyObject) kv.key;
        output.add(String.format(Colors.LightGray + "%-20s " + Colors.Gold + "|" + Colors.Blue + " %s", TownyFormatter.getFormattedName(town), TownyEconomyHandler.getFormattedBalance((Double) kv.value)));
    }
    return output;
}
Also used : KeyValueTable(com.palmergames.util.KeyValueTable) ArrayList(java.util.ArrayList) TownyEconomyObject(com.palmergames.bukkit.towny.object.TownyEconomyObject)

Aggregations

TownyEconomyObject (com.palmergames.bukkit.towny.object.TownyEconomyObject)1 KeyValueTable (com.palmergames.util.KeyValueTable)1 ArrayList (java.util.ArrayList)1