Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 28 additions & 6 deletions src/main/java/org/garsooon/AuctionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading