Took 7 minutes
This commit is contained in:
Kiran Hart 2022-10-05 18:23:17 -04:00
parent 5e5f8ab2f6
commit 890cd1f2b8
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3

View File

@ -17,6 +17,7 @@ import ca.tweetzy.core.input.PlayerChatInput;
import ca.tweetzy.core.utils.NumberUtils;
import ca.tweetzy.core.utils.PlayerUtils;
import ca.tweetzy.core.utils.TextUtils;
import lombok.NonNull;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.inventory.ClickType;
@ -160,6 +161,10 @@ public class GUISellItem extends AbstractPlaceholderGui {
put("%remaining_seconds%", times[3]);
}}), ClickType.LEFT, e -> {
e.gui.close();
// work-around to clicking closeable item with item on cursor
handleClosableCursorItem(e);
PlayerChatInput.PlayerChatInputBuilder<Long> builder = new PlayerChatInput.PlayerChatInputBuilder<>(AuctionHouse.getInstance(), e.player);
builder.isValidInput((p, str) -> {
String[] parts = ChatColor.stripColor(str).split(" ");
@ -193,8 +198,12 @@ public class GUISellItem extends AbstractPlaceholderGui {
}}), ClickType.LEFT, e -> {
setTheItemToBeListed();
setAllowClose(true);
e.gui.close();
// work-around to clicking closeable item with item on cursor
handleClosableCursorItem(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)) {
@ -225,8 +234,12 @@ public class GUISellItem extends AbstractPlaceholderGui {
}}), ClickType.LEFT, e -> {
setTheItemToBeListed();
setAllowClose(true);
e.gui.close();
// work-around to clicking closeable item with item on cursor
handleClosableCursorItem(e);
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);
@ -253,8 +266,12 @@ public class GUISellItem extends AbstractPlaceholderGui {
}}), ClickType.LEFT, e -> {
setTheItemToBeListed();
setAllowClose(true);
e.gui.close();
// work-around to clicking closeable item with item on cursor
handleClosableCursorItem(e);
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);
@ -453,10 +470,20 @@ public class GUISellItem extends AbstractPlaceholderGui {
AuctionHouse.getInstance().getAuctionPlayerManager().getUsingSellGUI().remove(e.player.getUniqueId());
setAllowClose(true);
e.gui.close();
if (e.cursor != null)
e.player.getInventory().addItem(e.cursor);
});
}
private void handleClosableCursorItem(@NonNull final GuiClickEvent e) {
if (e.cursor != null) {
AuctionHouse.getInstance().getAuctionPlayerManager().addItemToSellHolding(player.getUniqueId(), e.cursor);
this.itemToBeListed = e.cursor.clone();
}
}
private boolean validateChatNumber(String input, double requirement, boolean checkMax) {
String val = ChatColor.stripColor(input);
if (checkMax)