mirror of
https://github.com/kiranhart/Auction-House.git
synced 2025-02-27 21:31:33 +01:00
2.41.1 - closes #1 and fixed issue where non bid items would become bid items after a reload/restart
This commit is contained in:
parent
cf6d1f799c
commit
785bdaae3e
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>ca.tweetzy</groupId>
|
||||
<artifactId>auctionhouse</artifactId>
|
||||
<version>2.41.0</version>
|
||||
<version>2.41.1</version>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -237,7 +237,7 @@ public final class CommandSell extends AbstractCommand {
|
||||
allowedTime,
|
||||
/* buy now price */ buyNowAllow ? buyNowPrice : -1,
|
||||
/* start bid price */ isBiddingItem ? startingBid : 0,
|
||||
/* bid inc price */ isBiddingItem ? bidIncrement != null ? bidIncrement : Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble() : 1,
|
||||
/* bid inc price */ isBiddingItem ? bidIncrement != null ? bidIncrement : Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble() : 0,
|
||||
isBiddingItem,
|
||||
isBundle,
|
||||
true
|
||||
@ -250,7 +250,7 @@ public final class CommandSell extends AbstractCommand {
|
||||
allowedTime,
|
||||
/* buy now price */ buyNowAllow ? buyNowPrice : -1,
|
||||
/* start bid price */ isBiddingItem ? startingBid : !buyNowAllow ? buyNowPrice : 0,
|
||||
/* bid inc price */ isBiddingItem ? bidIncrement != null ? bidIncrement : Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble() : 1,
|
||||
/* bid inc price */ isBiddingItem ? bidIncrement != null ? bidIncrement : Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble() : 0,
|
||||
/* current price */ isBiddingItem ? startingBid : buyNowPrice <= -1 ? startingBid : buyNowPrice,
|
||||
isBiddingItem || !buyNowAllow,
|
||||
isBundle,
|
||||
|
@ -187,7 +187,7 @@ public class GUIAuctionHouse extends Gui {
|
||||
|
||||
private void handleBidItem(AuctionedItem auctionItem, GuiClickEvent e, boolean buyNow) {
|
||||
if (buyNow) {
|
||||
if (auctionItem.getBidStartingPrice() >= Settings.MIN_AUCTION_START_PRICE.getDouble()) {
|
||||
if (auctionItem.isBidItem()) {
|
||||
if (!Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean()) return;
|
||||
if (auctionItem.getBasePrice() <= -1) {
|
||||
AuctionHouse.getInstance().getLocale().getMessage("general.buynowdisabledonitem").sendPrefixedMessage(e.player);
|
||||
|
@ -149,7 +149,7 @@ public class GUISellItem extends Gui {
|
||||
e.gui.close();
|
||||
PlayerChatInput.PlayerChatInputBuilder<Long> builder = new PlayerChatInput.PlayerChatInputBuilder<>(AuctionHouse.getInstance(), e.player);
|
||||
builder.isValidInput((p, str) -> {
|
||||
String[] parts = str.split(" ");
|
||||
String[] parts = ChatColor.stripColor(str).split(" ");
|
||||
if (parts.length == 2) {
|
||||
if (NumberUtils.isInt(parts[0]) && Arrays.asList("second", "minute", "hour", "day", "week", "month", "year").contains(parts[1].toLowerCase())) {
|
||||
return AuctionAPI.toTicks(str) <= Settings.MAX_CUSTOM_DEFINED_TIME.getInt();
|
||||
@ -161,7 +161,7 @@ public class GUISellItem extends Gui {
|
||||
builder.invalidInputMessage(TextUtils.formatText(AuctionHouse.getInstance().getLocale().getMessage("prompts.enter valid listing time").getMessage()));
|
||||
builder.toCancel("cancel");
|
||||
builder.onCancel(p -> reopen(e));
|
||||
builder.setValue((p, value) -> AuctionAPI.toTicks(value));
|
||||
builder.setValue((p, value) -> AuctionAPI.toTicks(ChatColor.stripColor(value)));
|
||||
builder.onFinish((p, value) -> {
|
||||
this.auctionTime = value.intValue();
|
||||
reopen(e);
|
||||
@ -180,19 +180,25 @@ public class GUISellItem extends Gui {
|
||||
setAllowClose(true);
|
||||
e.gui.close();
|
||||
|
||||
ChatPrompt.showPrompt(AuctionHouse.getInstance(), this.auctionPlayer.getPlayer(), TextUtils.formatText(AuctionHouse.getInstance().getLocale().getMessage("prompts.enter new buy now price").getMessage()), chat -> {
|
||||
String msg = chat.getMessage();
|
||||
if (validateChatNumber(msg, Settings.MIN_AUCTION_PRICE.getDouble(), false) && validateChatNumber(msg, Settings.MAX_AUCTION_PRICE.getDouble(), true)) {
|
||||
// check if the buy now price is higher than the bid start price
|
||||
if (this.isAllowingBuyNow && this.isBiddingItem && Settings.BASE_PRICE_MUST_BE_HIGHER_THAN_BID_START.getBoolean() && Double.parseDouble(msg) < this.bidStartPrice) {
|
||||
reopen(e);
|
||||
return;
|
||||
}
|
||||
|
||||
this.buyNowPrice = Double.parseDouble(msg);
|
||||
reopen(e);
|
||||
PlayerChatInput.PlayerChatInputBuilder<Double> builder = new PlayerChatInput.PlayerChatInputBuilder<>(AuctionHouse.getInstance(), e.player);
|
||||
builder.isValidInput((p, str) -> {
|
||||
if (validateChatNumber(str, Settings.MIN_AUCTION_PRICE.getDouble(), false) && validateChatNumber(str, Settings.MAX_AUCTION_PRICE.getDouble(), true)) {
|
||||
return !this.isAllowingBuyNow || !this.isBiddingItem || !Settings.BASE_PRICE_MUST_BE_HIGHER_THAN_BID_START.getBoolean() || !(Double.parseDouble(str) < this.bidStartPrice);
|
||||
}
|
||||
}).setOnCancel(() -> reopen(e)).setOnClose(() -> reopen(e));
|
||||
return false;
|
||||
});
|
||||
|
||||
builder.sendValueMessage(TextUtils.formatText(AuctionHouse.getInstance().getLocale().getMessage("prompts.enter new buy now price").getMessage()));
|
||||
builder.toCancel("cancel");
|
||||
builder.onCancel(p -> reopen(e));
|
||||
builder.setValue((p, value) -> Double.parseDouble(ChatColor.stripColor(value)));
|
||||
builder.onFinish((p, value) -> {
|
||||
this.buyNowPrice = value;
|
||||
reopen(e);
|
||||
});
|
||||
|
||||
PlayerChatInput<Double> input = builder.build();
|
||||
input.start();
|
||||
});
|
||||
}
|
||||
|
||||
@ -203,13 +209,23 @@ public class GUISellItem extends Gui {
|
||||
setTheItemToBeListed();
|
||||
setAllowClose(true);
|
||||
e.gui.close();
|
||||
ChatPrompt.showPrompt(AuctionHouse.getInstance(), this.auctionPlayer.getPlayer(), TextUtils.formatText(AuctionHouse.getInstance().getLocale().getMessage("prompts.enter new starting bid").getMessage()), chat -> {
|
||||
String msg = chat.getMessage();
|
||||
if (validateChatNumber(msg, Settings.MIN_AUCTION_START_PRICE.getDouble(), false) && validateChatNumber(msg, Settings.MAX_AUCTION_START_PRICE.getDouble(), true)) {
|
||||
this.bidStartPrice = Double.parseDouble(msg);
|
||||
}
|
||||
|
||||
PlayerChatInput.PlayerChatInputBuilder<Double> builder = new PlayerChatInput.PlayerChatInputBuilder<>(AuctionHouse.getInstance(), e.player);
|
||||
builder.isValidInput((p, str) -> {
|
||||
return validateChatNumber(str, Settings.MIN_AUCTION_START_PRICE.getDouble(), false) && validateChatNumber(str, Settings.MAX_AUCTION_START_PRICE.getDouble(), true);
|
||||
});
|
||||
|
||||
builder.sendValueMessage(TextUtils.formatText(AuctionHouse.getInstance().getLocale().getMessage("prompts.enter new starting bid").getMessage()));
|
||||
builder.toCancel("cancel");
|
||||
builder.onCancel(p -> reopen(e));
|
||||
builder.setValue((p, value) -> Double.parseDouble(ChatColor.stripColor(value)));
|
||||
builder.onFinish((p, value) -> {
|
||||
this.bidStartPrice = value;
|
||||
reopen(e);
|
||||
}).setOnCancel(() -> reopen(e)).setOnClose(() -> reopen(e));
|
||||
});
|
||||
|
||||
PlayerChatInput<Double> input = builder.build();
|
||||
input.start();
|
||||
});
|
||||
|
||||
if (!Settings.FORCE_CUSTOM_BID_AMOUNT.getBoolean()) {
|
||||
@ -219,13 +235,23 @@ public class GUISellItem extends Gui {
|
||||
setTheItemToBeListed();
|
||||
setAllowClose(true);
|
||||
e.gui.close();
|
||||
ChatPrompt.showPrompt(AuctionHouse.getInstance(), this.auctionPlayer.getPlayer(), TextUtils.formatText(AuctionHouse.getInstance().getLocale().getMessage("prompts.enter new bid increment").getMessage()), chat -> {
|
||||
String msg = chat.getMessage();
|
||||
if (validateChatNumber(msg, Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble(), false) && validateChatNumber(msg, Settings.MAX_AUCTION_INCREMENT_PRICE.getDouble(), true)) {
|
||||
this.bidIncrementPrice = Double.parseDouble(msg);
|
||||
}
|
||||
|
||||
PlayerChatInput.PlayerChatInputBuilder<Double> builder = new PlayerChatInput.PlayerChatInputBuilder<>(AuctionHouse.getInstance(), e.player);
|
||||
builder.isValidInput((p, str) -> {
|
||||
return validateChatNumber(str, Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble(), false) && validateChatNumber(str, Settings.MAX_AUCTION_INCREMENT_PRICE.getDouble(), true);
|
||||
});
|
||||
|
||||
builder.sendValueMessage(TextUtils.formatText(AuctionHouse.getInstance().getLocale().getMessage("prompts.enter new bid increment").getMessage()));
|
||||
builder.toCancel("cancel");
|
||||
builder.onCancel(p -> reopen(e));
|
||||
builder.setValue((p, value) -> Double.parseDouble(ChatColor.stripColor(value)));
|
||||
builder.onFinish((p, value) -> {
|
||||
this.bidIncrementPrice = value;
|
||||
reopen(e);
|
||||
}).setOnCancel(() -> reopen(e)).setOnClose(() -> reopen(e));
|
||||
});
|
||||
|
||||
PlayerChatInput<Double> input = builder.build();
|
||||
input.start();
|
||||
});
|
||||
}
|
||||
|
||||
@ -337,9 +363,10 @@ public class GUISellItem extends Gui {
|
||||
}
|
||||
|
||||
private boolean validateChatNumber(String input, double requirement, boolean checkMax) {
|
||||
String val = ChatColor.stripColor(input);
|
||||
if (checkMax)
|
||||
return input != null && input.length() != 0 && NumberUtils.isDouble(input) && Double.parseDouble(input) <= requirement;
|
||||
return input != null && input.length() != 0 && NumberUtils.isDouble(input) && Double.parseDouble(input) >= requirement;
|
||||
return val != null && val.length() != 0 && NumberUtils.isDouble(val) && Double.parseDouble(val) <= requirement;
|
||||
return val != null && val.length() != 0 && NumberUtils.isDouble(val) && Double.parseDouble(val) >= requirement;
|
||||
}
|
||||
|
||||
private void reopen(GuiClickEvent e) {
|
||||
|
Loading…
Reference in New Issue
Block a user