Skip to content

Commit

Permalink
- Fix DailyTimerTask not resetting cosmetic list of removedTowns,
Browse files Browse the repository at this point in the history
removedNations, totalUpkeeps.
  - Fix towns being kicked from a nation for non-payment of taxes being
included in the removedTowns.
  • Loading branch information
LlmDl committed Feb 27, 2020
1 parent 56f3e8a commit 3722488
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 3 additions & 1 deletion resources/ChangeLog.txt
Expand Up @@ -4194,4 +4194,6 @@ v0.92.0.11:
0.95.2.19:
- Fix tw-ZH.yml courtesy of shou692199 with PR #3719.
- Fix to the preventPVP function, allowing for towns with PVP off to set PVP true on individual plots, courtesy of silverwolfg11 with PR #3718.
- Language files bumped to 0.72.
- Language files bumped to 0.72.
- Fix DailyTimerTask not resetting cosmetic list of removedTowns, removedNations, totalUpkeeps.
- Fix towns being kicked from a nation for non-payment of taxes being included in the removedTowns.
16 changes: 11 additions & 5 deletions src/com/palmergames/bukkit/towny/tasks/DailyTimerTask.java
Expand Up @@ -43,6 +43,10 @@ public DailyTimerTask(Towny plugin) {
public void run() {

long start = System.currentTimeMillis();
totalTownUpkeep = 0.0;
totalNationUpkeep = 0.0;
removedTowns.clear();
removedNations.clear();

TownyMessaging.sendDebugMsg("New Day");

Expand Down Expand Up @@ -176,8 +180,10 @@ public void collectNationTaxes() throws EconomyException {
* @throws EconomyException - EconomyException
*/
protected void collectNationTaxes(Nation nation) throws EconomyException {

if (nation.getTaxes() > 0) {

List<String> localRemovedTowns = null;
List<Town> towns = new ArrayList<>(nation.getTowns());
ListIterator<Town> townItr = towns.listIterator();
Town town;
Expand All @@ -196,7 +202,7 @@ protected void collectNationTaxes(Nation nation) throws EconomyException {
continue;
if (!town.getAccount().payTo(nation.getTaxes(), nation, "Nation Tax")) {
try {
removedTowns.add(town.getName());
localRemovedTowns.add(town.getName());
nation.removeTown(town);
} catch (EmptyNationException e) {
// Always has 1 town (capital) so ignore
Expand All @@ -208,11 +214,11 @@ protected void collectNationTaxes(Nation nation) throws EconomyException {
} else
TownyMessaging.sendPrefixedTownMessage(town, TownySettings.getPayedTownTaxMsg() + nation.getTaxes());
}
if (removedTowns != null) {
if (removedTowns.size() == 1)
TownyMessaging.sendNationMessagePrefixed(nation, String.format(TownySettings.getLangString("msg_couldnt_pay_tax"), ChatTools.list(removedTowns), "nation"));
if (!localRemovedTowns.isEmpty()) {
if (localRemovedTowns.size() == 1)
TownyMessaging.sendNationMessagePrefixed(nation, String.format(TownySettings.getLangString("msg_couldnt_pay_tax"), ChatTools.list(localRemovedTowns), "nation"));
else
TownyMessaging.sendNationMessagePrefixed(nation, ChatTools.list(removedTowns, TownySettings.getLangString("msg_couldnt_pay_nation_tax_multiple")));
TownyMessaging.sendNationMessagePrefixed(nation, ChatTools.list(localRemovedTowns, TownySettings.getLangString("msg_couldnt_pay_nation_tax_multiple")));
}
}

Expand Down

0 comments on commit 3722488

Please sign in to comment.