Use doubles for tax amount in config instead of int (Fixes #578)

For some reason this already was a float internally but not exposed in the config? Wat.
This commit is contained in:
Phoenix616 2024-04-26 16:42:59 +01:00
parent 46d4f583ba
commit 488cd2e9d5
No known key found for this signature in database
GPG Key ID: 40E2321E71738EB0
2 changed files with 6 additions and 6 deletions

View File

@ -190,10 +190,10 @@ public class Properties {
public static UUID SERVER_ECONOMY_ACCOUNT_UUID = new UUID(0, 0);
@ConfigurationComment("Percent of the price that should go to the server's account. (100 = 100 percent)")
public static int TAX_AMOUNT = 0;
public static double TAX_AMOUNT = 0;
@ConfigurationComment("Percent of the price that should go to the server's account when buying from an Admin Shop.")
public static int SERVER_TAX_AMOUNT = 0;
public static double SERVER_TAX_AMOUNT = 0;
@ConfigurationComment("Amount of money player must pay to create a shop")
public static BigDecimal SHOP_CREATION_PRICE = BigDecimal.valueOf(0);

View File

@ -20,8 +20,8 @@ public class TaxModule implements Listener {
private static final String TAX_RECEIVED_MESSAGE = "Applied a tax of %1$f percent (%2$.2f) to the received amount for a resulting price of %3$.2f";
private static final String TAX_SENT_MESSAGE = "Reduced buy price by tax of %1$f percent (%2$.2f) for a resulting price of %3$.2f as the buyer has the buy tax bypass permission";
private static float getTax(UUID partner) {
float taxAmount = NameManager.isAdminShop(partner) || NameManager.isServerEconomyAccount(partner)
private static double getTax(UUID partner) {
double taxAmount = NameManager.isAdminShop(partner) || NameManager.isServerEconomyAccount(partner)
? Properties.SERVER_TAX_AMOUNT : Properties.TAX_AMOUNT;
if (taxAmount == 0) {
@ -31,7 +31,7 @@ public class TaxModule implements Listener {
return taxAmount;
}
private static BigDecimal getTaxAmount(BigDecimal price, float taxAmount) {
private static BigDecimal getTaxAmount(BigDecimal price, double taxAmount) {
return price.multiply(BigDecimal.valueOf(taxAmount)).divide(BigDecimal.valueOf(100), Properties.PRICE_PRECISION, BigDecimal.ROUND_HALF_UP);
}
@ -41,7 +41,7 @@ public class TaxModule implements Listener {
return;
}
float taxAmount = getTax(event.getPartner());
double taxAmount = getTax(event.getPartner());
if (taxAmount == 0) {
return;
}