From 96a6a5a8d2fcc2d47f099922a54c808ed2f539f3 Mon Sep 17 00:00:00 2001 From: Kiran Hart Date: Fri, 28 Apr 2023 11:54:35 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=B2=20Fixed=20bid=20increment=20logic?= =?UTF-8?q?=20to=20make=20more=20sense=20when=20using=20realistic=20biddin?= =?UTF-8?q?g=20mode.=20Closes=20#52?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Took 15 minutes --- .../ahv3/impl/auction/AuctionBid.java | 1 - .../auctionhouse/commands/CommandSell.java | 6 ++---- .../ca/tweetzy/auctionhouse/guis/GUIBid.java | 16 +++++++++++++++- .../guis/confirmation/GUIConfirmBid.java | 6 +++--- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/main/java/ca/tweetzy/auctionhouse/ahv3/impl/auction/AuctionBid.java b/src/main/java/ca/tweetzy/auctionhouse/ahv3/impl/auction/AuctionBid.java index 487c8c3..4dd6f1e 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/ahv3/impl/auction/AuctionBid.java +++ b/src/main/java/ca/tweetzy/auctionhouse/ahv3/impl/auction/AuctionBid.java @@ -68,6 +68,5 @@ public final class AuctionBid implements Bid { @Override public void store(Consumer storedItem) { - // TODO implement auction bid store } } diff --git a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java index e9fcd49..206b71b 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java +++ b/src/main/java/ca/tweetzy/auctionhouse/commands/CommandSell.java @@ -205,8 +205,7 @@ public final class CommandSell extends AbstractCommand { final boolean isBiddingItem = Settings.FORCE_AUCTION_USAGE.getBoolean() || buyNowPrice != null && startingBid != null && Settings.ALLOW_USAGE_OF_BID_SYSTEM.getBoolean(); // NOT USING THE BIDDING SYSTEM - if (!isBiddingItem /* && buyNowPrice != null */) { - // min item price todo fix it broke + if (!isBiddingItem) { if (!AuctionAPI.getInstance().meetsMinItemPrice(isBundle, isBiddingItem, originalItem, buyNowPrice, isBiddingItem ? startingBid : 0)) { instance.getLocale().getMessage("pricing.minitemprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(instance.getMinItemPriceManager().getMinPrice(originalItem).getPrice())).sendPrefixedMessage(player); return ReturnType.FAILURE; @@ -216,8 +215,7 @@ public final class CommandSell extends AbstractCommand { if (!checkBasePrice(player, buyNowPrice, false)) return ReturnType.FAILURE; } - if (isBiddingItem && /* buyNowPrice != null && */ startingBid != null) { - // min item price todo fix it broke + if (isBiddingItem && startingBid != null) { if (!AuctionAPI.getInstance().meetsMinItemPrice(isBundle, isBiddingItem, originalItem, buyNowPrice, isBiddingItem ? startingBid : 0)) { instance.getLocale().getMessage("pricing.minitemprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(instance.getMinItemPriceManager().getMinPrice(originalItem).getPrice())).sendPrefixedMessage(player); return ReturnType.FAILURE; diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIBid.java b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIBid.java index 3364ebb..491cc8e 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/GUIBid.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/GUIBid.java @@ -73,7 +73,10 @@ public class GUIBid extends AbstractPlaceholderGui { } e.gui.exit(); - e.manager.showGUI(e.player, new GUIConfirmBid(this.auctionPlayer, auctionItem)); + // THE MINIMUM + final double minBid = Settings.USE_REALISTIC_BIDDING.getBoolean() ? this.auctionItem.getCurrentPrice() + this.auctionItem.getBidIncrementPrice() : this.auctionItem.getBidIncrementPrice(); + + e.manager.showGUI(e.player, new GUIConfirmBid(this.auctionPlayer, auctionItem, minBid)); }); // TODO UPDATE BID @@ -110,6 +113,11 @@ public class GUIBid extends AbstractPlaceholderGui { double newBiddingAmount = 0; if (Settings.USE_REALISTIC_BIDDING.getBoolean()) { + if (value < auctionItem.getCurrentPrice() + auctionItem.getBidIncrementPrice()) { + AuctionHouse.getInstance().getLocale().getMessage("pricing.minbidincrementprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(auctionItem.getCurrentPrice() + auctionItem.getBidIncrementPrice())).sendPrefixedMessage(e.player); + return false; + } + if (value > GUIBid.this.auctionItem.getCurrentPrice()) { newBiddingAmount = value; } else { @@ -122,6 +130,11 @@ public class GUIBid extends AbstractPlaceholderGui { newBiddingAmount = GUIBid.this.auctionItem.getCurrentPrice() + value; } } else { + if (value < auctionItem.getBidIncrementPrice()) { + AuctionHouse.getInstance().getLocale().getMessage("pricing.minbidincrementprice").processPlaceholder("price", AuctionAPI.getInstance().formatNumber(auctionItem.getBidIncrementPrice())).sendPrefixedMessage(e.player); + return false; + } + newBiddingAmount = GUIBid.this.auctionItem.getCurrentPrice() + value; } @@ -181,6 +194,7 @@ public class GUIBid extends AbstractPlaceholderGui { auctionItem.setHighestBidder(e.player.getUniqueId()); auctionItem.setHighestBidderName(e.player.getName()); auctionItem.setCurrentPrice(newBiddingAmount); + if (auctionItem.getBasePrice() != -1 && Settings.SYNC_BASE_PRICE_TO_HIGHEST_PRICE.getBoolean() && auctionItem.getCurrentPrice() > auctionItem.getBasePrice()) { auctionItem.setBasePrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(auctionItem.getCurrentPrice()) : auctionItem.getCurrentPrice()); } diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmBid.java b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmBid.java index 48f8586..f667ad6 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmBid.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIConfirmBid.java @@ -49,9 +49,9 @@ public class GUIConfirmBid extends AbstractPlaceholderGui { private final double bidAmount; private BukkitTask bukkitTask; - public GUIConfirmBid(AuctionPlayer auctionPlayer, AuctionedItem auctionItem) { - this(auctionPlayer, auctionItem, -1); - } +// public GUIConfirmBid(AuctionPlayer auctionPlayer, AuctionedItem auctionItem) { +// this(auctionPlayer, auctionItem, -1); +// } public GUIConfirmBid(AuctionPlayer auctionPlayer, AuctionedItem auctionItem, double bidAmount) { super(auctionPlayer);