Skip to content

Commit

Permalink
Fix /towny top balance (#5839)
Browse files Browse the repository at this point in the history
* Fix /towny top balance not working by making it run sync again

* Just make the balance code run async entirely
  • Loading branch information
altruiis authored Mar 30, 2022
1 parent 14b530a commit c97ae05
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions src/com/palmergames/bukkit/towny/command/TownyCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -352,23 +352,28 @@ else if (args[0].equalsIgnoreCase("land"))
} else
TownyMessaging.sendErrorMsg(sender, Translatable.of("msg_err_invalid_sub"));
else if (args[0].equalsIgnoreCase("balance")) {
if (args.length == 1 || args[1].equalsIgnoreCase("all")) {
List<Government> list = new ArrayList<>();
list.addAll(universe.getTowns());
list.addAll(universe.getNations());
townyTop.add(ChatTools.formatTitle("Top Bank Balances"));
Bukkit.getScheduler().runTaskAsynchronously(plugin, ()-> townyTop.addAll(getTopBankBalance(list)));
} else if (args[1].equalsIgnoreCase("town")) {
List<Government> list = new ArrayList<>(universe.getTowns());
townyTop.add(ChatTools.formatTitle("Top Bank Balances by Town"));
Bukkit.getScheduler().runTaskAsynchronously(plugin, ()-> townyTop.addAll(getTopBankBalance(list)));
} else if (args[1].equalsIgnoreCase("nation")) {
List<Government> list = new ArrayList<>(universe.getNations());
townyTop.add(ChatTools.formatTitle("Top Bank Balances by Nation"));
Bukkit.getScheduler().runTaskAsynchronously(plugin, ()-> townyTop.addAll(getTopBankBalance(list)));
} else {
TownyMessaging.sendErrorMsg(sender, Translatable.of("msg_err_invalid_sub"));
}
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
if (args.length == 1 || args[1].equalsIgnoreCase("all")) {
List<Government> list = new ArrayList<>();
list.addAll(universe.getTowns());
list.addAll(universe.getNations());
townyTop.add(ChatTools.formatTitle("Top Bank Balances"));
townyTop.addAll(getTopBankBalance(list));
} else if (args[1].equalsIgnoreCase("town")) {
List<Government> list = new ArrayList<>(universe.getTowns());
townyTop.add(ChatTools.formatTitle("Top Bank Balances by Town"));
townyTop.addAll(getTopBankBalance(list));
} else if (args[1].equalsIgnoreCase("nation")) {
List<Government> list = new ArrayList<>(universe.getNations());
townyTop.add(ChatTools.formatTitle("Top Bank Balances by Nation"));
townyTop.addAll(getTopBankBalance(list));
} else {
TownyMessaging.sendErrorMsg(sender, Translatable.of("msg_err_invalid_sub"));
}
for (String line : townyTop)
TownyMessaging.sendMessage(sender, line);
});
return;
}
else
TownyMessaging.sendErrorMsg(sender, Translatable.of("msg_err_invalid_sub"));
Expand Down

0 comments on commit c97ae05

Please sign in to comment.