From e8798fc18be02cf1bfacb900e79192bbf5b8ffd8 Mon Sep 17 00:00:00 2001 From: Kiran Hart Date: Fri, 18 Mar 2022 13:53:11 -0400 Subject: [PATCH] calculateListingFee using actual listing fee if not using percentage option Took 7 minutes --- .../tweetzy/auctionhouse/api/AuctionAPI.java | 32 +++++++++---------- .../listeners/AuctionListeners.java | 17 +++++----- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java b/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java index e46845d..071e144 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java +++ b/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java @@ -5,8 +5,8 @@ import ca.tweetzy.auctionhouse.api.events.AuctionStartEvent; import ca.tweetzy.auctionhouse.api.hook.MMOItemsHook; import ca.tweetzy.auctionhouse.api.hook.McMMOHook; import ca.tweetzy.auctionhouse.auction.AuctionPlayer; -import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType; import ca.tweetzy.auctionhouse.auction.AuctionedItem; +import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType; import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper; import ca.tweetzy.auctionhouse.helpers.MaterialCategorizer; import ca.tweetzy.auctionhouse.managers.SoundManager; @@ -605,27 +605,27 @@ public class AuctionAPI { } private double calculateListingFee(double basePrice) { - return Settings.TAX_LISTING_FEE_PERCENTAGE.getBoolean() ? (Settings.TAX_LISTING_FEE.getDouble() /100D) * basePrice : basePrice; + return Settings.TAX_LISTING_FEE_PERCENTAGE.getBoolean() ? (Settings.TAX_LISTING_FEE.getDouble() / 100D) * basePrice : Settings.TAX_LISTING_FEE.getDouble(); } 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); } - /** - * Used to insert an auction into the database - * - * @param seller Is the player who is listing the item - * @param item Is the item stack being listed to the auction house - * @param original Is the original item stack (only applies if using a bundle) - * @param seconds Is the total amount of seconds the item will be active for - * @param basePrice Is the buy now price - * @param bidStartPrice Is the price the bidding will start at if the item is an auction - * @param bidIncPrice Is the default price increment for an auction - * @param currentPrice Is the current/start price of an item - * @param isBiddingItem States whether the item is an auction or bin item - * @param isUsingBundle States whether the item is a bundled item - */ + /** + * Used to insert an auction into the database + * + * @param seller Is the player who is listing the item + * @param item Is the item stack being listed to the auction house + * @param original Is the original item stack (only applies if using a bundle) + * @param seconds Is the total amount of seconds the item will be active for + * @param basePrice Is the buy now price + * @param bidStartPrice Is the price the bidding will start at if the item is an auction + * @param bidIncPrice Is the default price increment for an auction + * @param currentPrice Is the current/start price of an item + * @param isBiddingItem States whether the item is an auction or bin item + * @param isUsingBundle States whether the item is a bundled item + */ 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, boolean isInfinite) { if (McMMOHook.isUsingAbility(seller)) { AuctionHouse.getInstance().getLocale().getMessage("general.mcmmo_ability_active").sendPrefixedMessage(seller); diff --git a/src/main/java/ca/tweetzy/auctionhouse/listeners/AuctionListeners.java b/src/main/java/ca/tweetzy/auctionhouse/listeners/AuctionListeners.java index dfc2ed3..9e45ecc 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/listeners/AuctionListeners.java +++ b/src/main/java/ca/tweetzy/auctionhouse/listeners/AuctionListeners.java @@ -6,13 +6,12 @@ import ca.tweetzy.auctionhouse.api.events.AuctionAdminEvent; import ca.tweetzy.auctionhouse.api.events.AuctionBidEvent; import ca.tweetzy.auctionhouse.api.events.AuctionEndEvent; import ca.tweetzy.auctionhouse.api.events.AuctionStartEvent; -import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType; import ca.tweetzy.auctionhouse.auction.AuctionStat; +import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.auctionhouse.transaction.Transaction; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import java.util.UUID; @@ -32,7 +31,7 @@ public class AuctionListeners implements Listener { )); if (Settings.DISCORD_ENABLED.getBoolean() && Settings.DISCORD_ALERT_ON_AUCTION_START.getBoolean()) { - Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(AuctionHouse.getInstance(), () -> { + AuctionHouse.newChain().async(() -> { Settings.DISCORD_WEBHOOKS.getStringList().forEach(hook -> { AuctionAPI.getInstance().sendDiscordMessage( hook, @@ -44,7 +43,7 @@ public class AuctionListeners implements Listener { e.getAuctionItem().isBidItem() ); }); - }, 1L); + }).execute(); } } @@ -66,7 +65,7 @@ public class AuctionListeners implements Listener { e.getSaleType() == AuctionSaleType.USED_BIDDING_SYSTEM ? e.getAuctionItem().getCurrentPrice() : e.getAuctionItem().getBasePrice() )); - Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(AuctionHouse.getInstance(), () -> { + AuctionHouse.newChain().async(() -> { if (Settings.RECORD_TRANSACTIONS.getBoolean()) { AuctionHouse.getInstance().getDataManager().insertTransactionAsync(new Transaction( @@ -90,15 +89,15 @@ public class AuctionListeners implements Listener { if (Settings.DISCORD_ENABLED.getBoolean() && Settings.DISCORD_ALERT_ON_AUCTION_FINISH.getBoolean()) { Settings.DISCORD_WEBHOOKS.getStringList().forEach(hook -> AuctionAPI.getInstance().sendDiscordMessage(hook, e.getOriginalOwner(), e.getBuyer(), e.getAuctionItem(), e.getSaleType(), false, e.getSaleType() == AuctionSaleType.USED_BIDDING_SYSTEM)); } - }, 1L); + }).execute(); } @EventHandler public void onAuctionBid(AuctionBidEvent e) { if (!Settings.DISCORD_ENABLED.getBoolean() && Settings.DISCORD_ALERT_ON_AUCTION_BID.getBoolean()) return; - Bukkit.getServer().getScheduler().runTaskLaterAsynchronously(AuctionHouse.getInstance(), () -> Settings.DISCORD_WEBHOOKS.getStringList().forEach(hook -> { - AuctionAPI.getInstance().sendDiscordBidMessage(hook, e.getAuctionedItem(), e.getNewBidAmount()); - }), 1L); + AuctionHouse.newChain().async(() -> { + Settings.DISCORD_WEBHOOKS.getStringList().forEach(hook -> AuctionAPI.getInstance().sendDiscordBidMessage(hook, e.getAuctionedItem(), e.getNewBidAmount())); + }).execute(); } @EventHandler