Fixed bug where sell menu would exit / not give item back if listing fee could not be paid

Took 2 minutes
This commit is contained in:
Kiran Hart 2022-07-27 15:54:11 -04:00
parent c9c6462f04
commit e161603868
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
2 changed files with 11 additions and 1 deletions

View File

@ -628,7 +628,7 @@ public class AuctionAPI {
return NBTEditor.contains(item, "AuctionHouseRepaired");
}
private double calculateListingFee(double basePrice) {
public double calculateListingFee(double basePrice) {
return Settings.TAX_LISTING_FEE_PERCENTAGE.getBoolean() ? (Settings.TAX_LISTING_FEE.getDouble() / 100D) * basePrice : Settings.TAX_LISTING_FEE.getDouble();
}

View File

@ -9,6 +9,7 @@ import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.compatibility.XMaterial;
import ca.tweetzy.core.gui.events.GuiClickEvent;
import ca.tweetzy.core.hooks.EconomyManager;
import ca.tweetzy.core.input.ChatPrompt;
import ca.tweetzy.core.input.PlayerChatInput;
import ca.tweetzy.core.utils.NumberUtils;
@ -330,6 +331,15 @@ public class GUISellItem extends AbstractPlaceholderGui {
return;
}
if (Settings.TAX_ENABLED.getBoolean() && Settings.TAX_CHARGE_LISTING_FEE.getBoolean()) {
final double listingFee = AuctionAPI.getInstance().calculateListingFee(this.isBiddingItem && !isAllowingBuyNow || !Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() ? -1 : buyNowPrice);
if (!EconomyManager.hasBalance(e.player, listingFee)) {
AuctionHouse.getInstance().getLocale().getMessage("auction.tax.cannotpaylistingfee").processPlaceholder("price", listingFee).sendPrefixedMessage(e.player);
return;
}
}
if (Settings.ASK_FOR_LISTING_CONFIRMATION.getBoolean()) {
setAllowClose(true);