Example #1
0
 public KeyValue<Town, Integer> getWinningTownScore() throws TownyException {
   KeyValueTable<Town, Integer> kvTable = new KeyValueTable<Town, Integer>(townScores);
   kvTable.sortByValue();
   kvTable.revese();
   if (kvTable.getKeyValues().size() > 0) return kvTable.getKeyValues().get(0);
   else throw new TownyException();
 }
Example #2
0
 /**
  * @param maxListing Maximum lines to return. Value of -1 return all.
  * @return A list of the current scores per town sorted in descending order.
  */
 public List<String> getScores(int maxListing) {
   List<String> output = new ArrayList<String>();
   output.add(ChatTools.formatTitle("War - Top Scores"));
   KeyValueTable<Town, Integer> kvTable = new KeyValueTable<Town, Integer>(townScores);
   kvTable.sortByValue();
   kvTable.revese();
   int n = 0;
   for (KeyValue<Town, Integer> kv : kvTable.getKeyValues()) {
     n++;
     if (maxListing != -1 && n > maxListing) break;
     Town town = (Town) kv.key;
     output.add(
         String.format(
             Colors.Blue + "%40s " + Colors.Gold + "|" + Colors.LightGray + " %4d",
             TownyFormatter.getFormattedName(town),
             (Integer) kv.value));
   }
   return output;
 }