Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix taxes being below 0 #4243

Merged
merged 1 commit into from
Aug 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/com/palmergames/bukkit/towny/object/Government.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public abstract class Government extends TownyObject implements BankEconomyHandl
private boolean isOpen = false;
private long registered;
private double spawnCost = TownySettings.getSpawnTravelCost();
protected double taxes = -1;
protected double taxes;
private final AccountAuditor accountAuditor = new GovernmentAccountAuditor();

protected Government(String name) {
Expand Down
17 changes: 6 additions & 11 deletions src/com/palmergames/bukkit/towny/object/Town.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public Town(String name) {
permissions.loadDefault(this);

// Set defaults.
setTaxes(TownySettings.getTownDefaultTax());
setOpen(TownySettings.getTownDefaultOpen());
setBoard(TownySettings.getTownDefaultBoard());
}
Expand Down Expand Up @@ -116,17 +117,11 @@ public Resident getMayor() {
}

public void setTaxes(double taxes) {
if (isTaxPercentage) {
this.taxes = Math.min(taxes, TownySettings.getMaxTownTaxPercent());
} else {
this.taxes = Math.min(taxes, TownySettings.getMaxTownTax());
}
}

@Override
public double getTaxes() {
setTaxes(taxes);
return taxes == -1 ? TownySettings.getTownDefaultTax() : taxes;
this.taxes = Math.min(taxes, isTaxPercentage ? TownySettings.getMaxTownTaxPercent() : TownySettings.getMaxTownTax());

// Fix invalid taxes
if (this.taxes < 0)
this.taxes = TownySettings.getTownDefaultTax();
}

public void setMayor(Resident mayor) throws TownyException {
Expand Down