tax can be set as a percentage of the list price rather than a hard set value

Took 8 minutes
This commit is contained in:
Kiran Hart 2022-02-11 20:48:00 -05:00
parent fc23963c3d
commit edbca7ab92
3 changed files with 13 additions and 8 deletions

View File

@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ca.tweetzy</groupId>
<artifactId>auctionhouse</artifactId>
<version>2.54.2</version>
<version>2.55.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -605,6 +605,10 @@ public class AuctionAPI {
return NBTEditor.contains(item, "AuctionHouseRepaired");
}
private double calculateListingFee(double basePrice) {
return Settings.TAX_LISTING_FEE_PERCENTAGE.getBoolean() ? (Settings.TAX_LISTING_FEE.getDouble() /100D) * basePrice : basePrice;
}
public void listAuction(Player seller, ItemStack original, ItemStack item, int seconds, double basePrice, double bidStartPrice, double bidIncPrice, double currentPrice, boolean isBiddingItem, boolean isUsingBundle, boolean requiresHandRemove) {
listAuction(seller, original, item, seconds, basePrice, bidStartPrice, bidIncPrice, currentPrice, isBiddingItem, isUsingBundle, requiresHandRemove, false);
}
@ -660,13 +664,13 @@ public class AuctionAPI {
auctionedItem.setInfinite(isInfinite);
if (Settings.TAX_ENABLED.getBoolean() && Settings.TAX_CHARGE_LISTING_FEE.getBoolean()) {
if (!EconomyManager.hasBalance(seller, Settings.TAX_LISTING_FEE.getDouble())) {
AuctionHouse.getInstance().getLocale().getMessage("auction.tax.cannotpaylistingfee").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_LISTING_FEE.getDouble())).sendPrefixedMessage(seller);
if (!EconomyManager.hasBalance(seller, calculateListingFee(basePrice))) {
AuctionHouse.getInstance().getLocale().getMessage("auction.tax.cannotpaylistingfee").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(calculateListingFee(basePrice))).sendPrefixedMessage(seller);
return;
}
EconomyManager.withdrawBalance(seller, Settings.TAX_LISTING_FEE.getDouble());
AuctionHouse.getInstance().getLocale().getMessage("auction.tax.paidlistingfee").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_LISTING_FEE.getDouble())).sendPrefixedMessage(seller);
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(seller))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_LISTING_FEE.getDouble())).sendPrefixedMessage(seller);
EconomyManager.withdrawBalance(seller, calculateListingFee(basePrice));
AuctionHouse.getInstance().getLocale().getMessage("auction.tax.paidlistingfee").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(calculateListingFee(basePrice))).sendPrefixedMessage(seller);
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyremove").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(seller))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(calculateListingFee(basePrice))).sendPrefixedMessage(seller);
}
AuctionStartEvent startEvent = new AuctionStartEvent(seller, auctionedItem);
@ -723,8 +727,8 @@ public class AuctionAPI {
// If the item could not be added for whatever reason and the tax listing fee is enabled, refund them
if (Settings.TAX_ENABLED.getBoolean() && Settings.TAX_CHARGE_LISTING_FEE.getBoolean()) {
EconomyManager.deposit(seller, Settings.TAX_LISTING_FEE.getDouble());
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(seller))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(Settings.TAX_LISTING_FEE.getDouble())).sendPrefixedMessage(seller);
EconomyManager.deposit(seller, calculateListingFee(basePrice));
AuctionHouse.getInstance().getLocale().getMessage("pricing.moneyadd").processPlaceholder("player_balance", AuctionAPI.getInstance().formatNumber(EconomyManager.getBalance(seller))).processPlaceholder("price", AuctionAPI.getInstance().formatNumber(calculateListingFee(basePrice))).sendPrefixedMessage(seller);
}
return;
}

View File

@ -121,6 +121,7 @@ public class Settings {
public static final ConfigSetting TAX_ENABLED = new ConfigSetting(config, "auction setting.tax.enabled", false, "Should auction house use it's tax system?");
public static final ConfigSetting TAX_CHARGE_LISTING_FEE = new ConfigSetting(config, "auction setting.tax.charge listing fee", true, "Should auction house charge players to list an item?");
public static final ConfigSetting TAX_LISTING_FEE = new ConfigSetting(config, "auction setting.tax.listing fee", 5.0, "How much should it cost to list a new item?");
public static final ConfigSetting TAX_LISTING_FEE_PERCENTAGE = new ConfigSetting(config, "auction setting.tax.listing fee is percentage", true, "Should the listing fee be based on a percentage instead?");
public static final ConfigSetting TAX_CHARGE_SALES_TAX_TO_BUYER = new ConfigSetting(config, "auction setting.tax.charge sale tax to buyer", false, "Should auction house tax the buyer instead of the seller?");
public static final ConfigSetting TAX_SALES_TAX_BUY_NOW_PERCENTAGE = new ConfigSetting(config, "auction setting.tax.buy now sales tax", 15.0, "Tax % that should be charged on items that are bought immediately");
public static final ConfigSetting TAX_SALES_TAX_AUCTION_WON_PERCENTAGE = new ConfigSetting(config, "auction setting.tax.auction won sales tax", 10.0, "Tax % that should be charged on items that are won through the auction");