Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
Use doubles for tax amount in config instead of int (Fixes ChestShop-…
Browse files Browse the repository at this point in the history
…authors#578)

For some reason this already was a float internally but not exposed in the config? Wat.
  • Loading branch information
Phoenix616 committed Apr 26, 2024
1 parent 46d4f58 commit 488cd2e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ public <T> Object parseToJava(Class<T> type, Object object) {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -31,7 +31,7 @@ private static float getTax(UUID partner) {
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);
}

Expand All @@ -41,7 +41,7 @@ public static void onCurrencyTransfer(CurrencyTransferEvent event) {
return;
}

float taxAmount = getTax(event.getPartner());
double taxAmount = getTax(event.getPartner());
if (taxAmount == 0) {
return;
}
Expand Down

0 comments on commit 488cd2e

Please sign in to comment.