diff --git a/src/main/java/org/garsooon/AuctionManager.java b/src/main/java/org/garsooon/AuctionManager.java index 2b666ba..a9c4c4a 100644 --- a/src/main/java/org/garsooon/AuctionManager.java +++ b/src/main/java/org/garsooon/AuctionManager.java @@ -80,13 +80,17 @@ public boolean startAuction(Player seller, ItemStack item, double price, String startPrice = roundDown2(price); - Object maxStartPriceObj = plugin.getCustomConfig().get("max-start-price"); - double maxStartPrice = 500.0; - if (maxStartPriceObj instanceof Number) { - maxStartPrice = ((Number) maxStartPriceObj).doubleValue(); + double minStartPrice = parseConfigDouble("min-start-price", 0); + double maxStartPrice = parseConfigDouble("max-start-price", 100000); + double minMinBidIncrease = parseConfigDouble("min-bid-increase", 1); + double maxBidIncrease = parseConfigDouble("max-bid-increase", 0); + + if (startPrice < minStartPrice) { + seller.sendMessage(ChatColor.RED + "The minimum auction start price is $" + roundDown2(minStartPrice)); + return false; } - if (startPrice > maxStartPrice) { - seller.sendMessage(ChatColor.RED + "The maximum auction start price is $" + String.format("%.2f", maxStartPrice)); + if (startPrice > maxStartPrice && maxStartPrice != 0) { + seller.sendMessage(ChatColor.RED + "The maximum auction start price is $" + roundDown2(maxStartPrice)); return false; } @@ -95,6 +99,15 @@ public boolean startAuction(Player seller, ItemStack item, double price, String parseIncrement(incrementArg); + if (minBidIncrement < minMinBidIncrease) { + seller.sendMessage(ChatColor.RED + "The minimum auction bid increase is $" + roundDown2(minMinBidIncrease)); + return false; + } + if (minBidIncrement > maxBidIncrease && maxBidIncrease != 0) { + seller.sendMessage(ChatColor.RED + "The maximum auction bid increase is $" + roundDown2(maxBidIncrease)); + return false; + } + currentSeller = seller; currentItem = item; @@ -180,6 +193,15 @@ private void parseIncrement(String arg) { } } + public double parseConfigDouble(String configName, double defaultNumber) { + Object configDoubleObj = plugin.getCustomConfig().get(configName); + double configDouble = defaultNumber; + if (configDoubleObj instanceof Number) { + configDouble = ((Number) configDoubleObj).doubleValue(); + } + return configDouble; + } + //Handles placing a bid on the current auction. public boolean bid(Player bidder, double amount) { if (currentItem == null || bidder == currentSeller) return false; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f2fec7a..58c60b0 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -12,9 +12,16 @@ time_add_per_bid: 10 # Maximum total auction time in seconds max_auction_time: 120 -# Maximum auction starting price +# Minimum/maximum auction starting price +min-start-price: 0 +# Use 0 for unlimited max-start-price: 100000 +# Minimum/maximum bid increase +min-bid-increase: 1 +# Use 0 for unlimited +max-bid-increase: 0 + blacklist: - BEDROCK - 44:4