fixed issues with confirmation gui, and NaN value being entered

Took 5 minutes
This commit is contained in:
Kiran Hart 2022-06-20 11:35:53 -04:00
parent d5e4a3dc51
commit 38c053fc30
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
3 changed files with 10 additions and 3 deletions

View File

@ -45,6 +45,7 @@ public class CommandAuctionHouse extends AbstractCommand {
}
if (args.length == 1 && AuctionHouse.getInstance().getCommandManager().getSubCommands("auctionhouse").stream().noneMatch(cmd -> cmd.equalsIgnoreCase(StringUtils.join(args, ' ').trim()))) {
if (args[0].equalsIgnoreCase("NaN")) return ReturnType.FAILURE;
AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUIAuctionHouse(AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(player.getUniqueId()), StringUtils.join(args, ' ').trim()));
}
}

View File

@ -144,7 +144,7 @@ public final class CommandSell extends AbstractCommand {
boolean partialBuy = false;
for (int i = 0; i < args.length; i++) {
if (NumberUtils.isDouble(args[i])) {
if (NumberUtils.isDouble(args[i]) && !Double.isNaN(Double.parseDouble(args[i]))) {
if (buyNowPrice == null)
buyNowPrice = Double.parseDouble(args[i]);
else if (startingBid == null)

View File

@ -3,7 +3,9 @@ package ca.tweetzy.auctionhouse.guis.confirmation;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.compatibility.CompatibleHand;
import ca.tweetzy.core.gui.Gui;
import ca.tweetzy.core.utils.PlayerUtils;
import ca.tweetzy.core.utils.TextUtils;
import ca.tweetzy.core.utils.items.TItemBuilder;
import org.bukkit.entity.Player;
@ -47,6 +49,9 @@ public class GUIConfirmListing extends AbstractPlaceholderGui {
this.requiresHandRemove = requiresHandRemove;
this.isInfinite = isInfinite;
setOnOpen(open -> PlayerUtils.takeActiveItem(open.player, CompatibleHand.MAIN_HAND, originalItem.getAmount()));
setOnClose(close -> close.player.getInventory().addItem(originalItem));
setTitle(TextUtils.formatText(Settings.GUI_CONFIRM_LISTING_TITLE.getString()));
setAcceptsItems(false);
setRows(1);
@ -63,7 +68,8 @@ public class GUIConfirmListing extends AbstractPlaceholderGui {
setItems(5, 8, new TItemBuilder(Objects.requireNonNull(Settings.GUI_CONFIRM_LISTING_NO_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_CONFIRM_LISTING_NO_NAME.getString()).setLore(Settings.GUI_CONFIRM_LISTING_NO_LORE.getStringList()).toItemStack());
setActionForRange(5, 8, ClickType.LEFT, e -> {
e.gui.close();
e.gui.exit();
e.player.getInventory().addItem(originalItem);
});
setActionForRange(0, 3, ClickType.LEFT, e -> {
@ -82,7 +88,7 @@ public class GUIConfirmListing extends AbstractPlaceholderGui {
this.isInfinite,
false
);
e.gui.close();
e.gui.exit();
});
}
}