remove old confirm listing in favour of new consumer version

Took 33 minutes
This commit is contained in:
Kiran Hart 2022-08-25 09:39:12 -04:00
parent 36070781cc
commit b33ecceefe
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
6 changed files with 250 additions and 174 deletions

View File

@ -12,7 +12,6 @@ import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
import ca.tweetzy.auctionhouse.helpers.MaterialCategorizer;
import ca.tweetzy.auctionhouse.managers.SoundManager;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.compatibility.CompatibleHand;
import ca.tweetzy.core.compatibility.ServerVersion;
import ca.tweetzy.core.compatibility.XMaterial;
import ca.tweetzy.core.hooks.EconomyManager;
@ -716,8 +715,11 @@ public class AuctionAPI {
ItemStack finalItemToSell = item.clone();
int totalOriginal = isUsingBundle ? AuctionAPI.getInstance().getItemCountInPlayerInventory(seller, original) : finalItemToSell.getAmount();
if (requiresHandRemove)
PlayerUtils.takeActiveItem(seller, CompatibleHand.MAIN_HAND, totalOriginal);
if (requiresHandRemove) {
removeSpecificItemQuantityFromPlayer(seller, finalItemToSell, totalOriginal);
}
// PlayerUtils.takeActiveItem(seller, CompatibleHand.MAIN_HAND, totalOriginal);
SoundManager.getInstance().playSound(seller, Settings.SOUNDS_LISTED_ITEM_ON_AUCTION_HOUSE.getString(), 1.0F, 1.0F);

View File

@ -3,10 +3,13 @@ package ca.tweetzy.auctionhouse.commands;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType;
import ca.tweetzy.auctionhouse.guis.GUIAuctionHouse;
import ca.tweetzy.auctionhouse.guis.GUIBundleCreation;
import ca.tweetzy.auctionhouse.guis.GUISellItem;
import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmListing;
import ca.tweetzy.auctionhouse.guis.confirmation.GUIListingConfirm;
import ca.tweetzy.auctionhouse.helpers.MaterialCategorizer;
import ca.tweetzy.auctionhouse.helpers.PlayerHelper;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.commands.AbstractCommand;
@ -24,6 +27,7 @@ import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
/**
@ -295,19 +299,66 @@ public final class CommandSell extends AbstractCommand {
}
if (Settings.ASK_FOR_LISTING_CONFIRMATION.getBoolean()) {
AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUIConfirmListing(
player,
originalItem,
itemToSell,
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() : 0,
isBiddingItem,
isBundle,
true,
isInfinite
));
// TODO clean up is monstrosity
AuctionedItem auctionedItem = new AuctionedItem();
auctionedItem.setId(UUID.randomUUID());
auctionedItem.setOwner(player.getUniqueId());
auctionedItem.setHighestBidder(player.getUniqueId());
auctionedItem.setOwnerName(player.getName());
auctionedItem.setHighestBidderName(player.getName());
auctionedItem.setItem(itemToSell);
auctionedItem.setCategory(MaterialCategorizer.getMaterialCategory(itemToSell));
auctionedItem.setExpiresAt(System.currentTimeMillis() + 1000L * allowedTime);
auctionedItem.setBidItem(isBiddingItem);
auctionedItem.setExpired(false);
auctionedItem.setBasePrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(buyNowAllow ? buyNowPrice : -1) : buyNowAllow ? buyNowPrice : -1);
auctionedItem.setBidStartingPrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(isBiddingItem ? startingBid : 0) : isBiddingItem ? startingBid : 0);
auctionedItem.setBidIncrementPrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(isBiddingItem ? bidIncrement != null ? bidIncrement : Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble() : 0) : isBiddingItem ? bidIncrement != null ? bidIncrement : Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble() : 0);
auctionedItem.setCurrentPrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(isBiddingItem ? startingBid : buyNowPrice <= -1 ? startingBid : buyNowPrice) : isBiddingItem ? startingBid : buyNowPrice <= -1 ? startingBid : buyNowPrice);
auctionedItem.setListedWorld(player.getWorld().getName());
auctionedItem.setInfinite(isInfinite);
auctionedItem.setAllowPartialBuy(partialBuy);
ItemStack finalItemToSell = itemToSell;
int finalAllowedTime = allowedTime;
Double finalBuyNowPrice = buyNowPrice;
Double finalStartingBid = startingBid;
Double finalBidIncrement = bidIncrement;
Double finalStartingBid1 = startingBid;
boolean finalIsInfinite = isInfinite;
boolean finalPartialBuy = partialBuy;
boolean finalIsBundle = isBundle;
AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUIListingConfirm(player, auctionedItem, result -> {
if (!result) {
player.closeInventory();
return;
}
AuctionAPI.getInstance().listAuction(
player,
originalItem,
finalItemToSell,
finalAllowedTime,
/* buy now price */ buyNowAllow ? finalBuyNowPrice : -1,
/* start bid price */ isBiddingItem ? finalStartingBid : !buyNowAllow ? finalBuyNowPrice : 0,
/* bid inc price */ isBiddingItem ? finalBidIncrement != null ? finalBidIncrement : Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble() : 0,
/* current price */ isBiddingItem ? finalStartingBid : finalBuyNowPrice <= -1 ? finalStartingBid1 : finalBuyNowPrice,
isBiddingItem || !buyNowAllow,
finalIsBundle,
true,
finalIsInfinite,
finalPartialBuy
);
player.closeInventory();
if (Settings.OPEN_MAIN_AUCTION_HOUSE_AFTER_MENU_LIST.getBoolean()) {
AuctionHouse.getInstance().getGuiManager().showGUI(player, new GUIAuctionHouse(AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(player.getUniqueId())));
}
}));
} else {
AuctionAPI.getInstance().listAuction(
player,

View File

@ -3,8 +3,10 @@ package ca.tweetzy.auctionhouse.guis;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmListing;
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
import ca.tweetzy.auctionhouse.guis.confirmation.GUIListingConfirm;
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
import ca.tweetzy.auctionhouse.helpers.MaterialCategorizer;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.compatibility.XMaterial;
import ca.tweetzy.core.utils.PlayerUtils;
@ -15,6 +17,7 @@ import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
/**
@ -117,19 +120,55 @@ public final class GUIBundleCreation extends AbstractPlaceholderGui {
if (Settings.ASK_FOR_LISTING_CONFIRMATION.getBoolean()) {
AuctionHouse.getInstance().getGuiManager().showGUI(player.getPlayer(), new GUIConfirmListing(
player.getPlayer(),
validItems.size() > 1 ? firstItem : validItems.get(0),
validItems.size() > 1 ? bundle : validItems.get(0),
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() : 0,
isBiddingItem,
true,
validItems.size() > 1,
false
));
// TODO clean up is monstrosity
AuctionedItem auctionedItem = new AuctionedItem();
auctionedItem.setId(UUID.randomUUID());
auctionedItem.setOwner(e.player.getUniqueId());
auctionedItem.setHighestBidder(e.player.getUniqueId());
auctionedItem.setOwnerName(e.player.getName());
auctionedItem.setHighestBidderName(e.player.getName());
auctionedItem.setItem(validItems.size() > 1 ? bundle : validItems.get(0));
auctionedItem.setCategory(MaterialCategorizer.getMaterialCategory(validItems.size() > 1 ? bundle : validItems.get(0)));
auctionedItem.setExpiresAt(System.currentTimeMillis() + 1000L * allowedTime);
auctionedItem.setBidItem(isBiddingItem);
auctionedItem.setExpired(false);
auctionedItem.setBasePrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(buyNowAllow ? buyNowPrice : -1) : buyNowAllow ? buyNowPrice : -1);
auctionedItem.setBidStartingPrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(isBiddingItem ? startingBid : !buyNowAllow ? buyNowPrice : 0) : isBiddingItem ? startingBid : !buyNowAllow ? buyNowPrice : 0);
auctionedItem.setBidIncrementPrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(isBiddingItem ? bidIncrement != null ? bidIncrement : Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble() : 0) : isBiddingItem ? bidIncrement != null ? bidIncrement : Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble() : 0);
auctionedItem.setCurrentPrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(isBiddingItem ? startingBid : buyNowPrice <= -1 ? startingBid : buyNowPrice) : isBiddingItem ? startingBid : buyNowPrice <= -1 ? startingBid : buyNowPrice);
auctionedItem.setListedWorld(e.player.getWorld().getName());
auctionedItem.setInfinite(false);
auctionedItem.setAllowPartialBuy(false);
ItemStack finalFirstItem = firstItem;
AuctionHouse.getInstance().getGuiManager().showGUI(e.player, new GUIListingConfirm(e.player, auctionedItem, result -> {
if (!result) {
e.player.closeInventory();
return;
}
AuctionAPI.getInstance().listAuction(
player.getPlayer(),
validItems.size() > 1 ? finalFirstItem : validItems.get(0),
validItems.size() > 1 ? bundle : validItems.get(0),
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() : 0,
/* current price */ isBiddingItem ? startingBid : buyNowPrice <= -1 ? startingBid : buyNowPrice,
isBiddingItem || !buyNowAllow,
validItems.size() > 1,
false
);
e.gui.exit();
if (Settings.OPEN_MAIN_AUCTION_HOUSE_AFTER_MENU_LIST.getBoolean()) {
e.manager.showGUI(e.player, new GUIAuctionHouse(player));
}
}));
} else {
AuctionAPI.getInstance().listAuction(
player.getPlayer(),

View File

@ -3,9 +3,11 @@ package ca.tweetzy.auctionhouse.guis;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType;
import ca.tweetzy.auctionhouse.guis.confirmation.GUIConfirmListing;
import ca.tweetzy.auctionhouse.guis.confirmation.GUIListingConfirm;
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
import ca.tweetzy.auctionhouse.helpers.MaterialCategorizer;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.compatibility.XMaterial;
import ca.tweetzy.core.gui.events.GuiClickEvent;
@ -22,6 +24,7 @@ import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
/**
@ -36,9 +39,9 @@ public class GUISellItem extends AbstractPlaceholderGui {
private final AuctionPlayer auctionPlayer;
private ItemStack itemToBeListed;
private double buyNowPrice;
private double bidStartPrice;
private double bidIncrementPrice;
private Double buyNowPrice;
private Double bidStartPrice;
private Double bidIncrementPrice;
private boolean isBiddingItem;
private boolean isAllowingBuyNow;
private int auctionTime;
@ -119,7 +122,7 @@ public class GUISellItem extends AbstractPlaceholderGui {
}
public GUISellItem(AuctionPlayer auctionPlayer, ItemStack itemToBeListed) {
this(auctionPlayer, itemToBeListed, Settings.MIN_AUCTION_PRICE.getDouble(), Settings.MIN_AUCTION_START_PRICE.getDouble(),Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble(), false, true, auctionPlayer.getAllowedSellTime(AuctionSaleType.WITHOUT_BIDDING_SYSTEM));
this(auctionPlayer, itemToBeListed, Settings.MIN_AUCTION_PRICE.getDouble(), Settings.MIN_AUCTION_START_PRICE.getDouble(), Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble(), false, true, auctionPlayer.getAllowedSellTime(AuctionSaleType.WITHOUT_BIDDING_SYSTEM));
}
private void draw() {
@ -346,19 +349,61 @@ public class GUISellItem extends AbstractPlaceholderGui {
}
setAllowClose(true);
AuctionHouse.getInstance().getGuiManager().showGUI(e.player, new GUIConfirmListing(
e.player,
this.itemToBeListed.clone(),
this.itemToBeListed.clone(),
this.auctionTime,
this.isBiddingItem && !isAllowingBuyNow || !Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() ? -1 : buyNowPrice,
this.isBiddingItem ? bidStartPrice : 0,
Settings.FORCE_CUSTOM_BID_AMOUNT.getBoolean() ? 1 : this.isBiddingItem ? bidIncrementPrice : 0,
this.isBiddingItem,
false,
false,
false
));
// TODO clean up is monstrosity
AuctionedItem auctionedItem = new AuctionedItem();
auctionedItem.setId(UUID.randomUUID());
auctionedItem.setOwner(e.player.getUniqueId());
auctionedItem.setHighestBidder(e.player.getUniqueId());
auctionedItem.setOwnerName(e.player.getName());
auctionedItem.setHighestBidderName(e.player.getName());
auctionedItem.setItem(this.itemToBeListed.clone());
auctionedItem.setCategory(MaterialCategorizer.getMaterialCategory(this.itemToBeListed.clone()));
auctionedItem.setExpiresAt(System.currentTimeMillis() + 1000L * this.auctionTime);
auctionedItem.setBidItem(isBiddingItem);
auctionedItem.setExpired(false);
auctionedItem.setBasePrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(this.isAllowingBuyNow ? buyNowPrice : -1) : this.isAllowingBuyNow ? buyNowPrice : -1);
auctionedItem.setBidStartingPrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(this.isBiddingItem ? this.bidStartPrice : 0) : this.isBiddingItem ? this.bidStartPrice : 0);
auctionedItem.setBidIncrementPrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(this.isBiddingItem ? this.bidIncrementPrice != null ? this.bidIncrementPrice : Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble() : 0) : this.isBiddingItem ? this.bidIncrementPrice != null ? this.bidIncrementPrice : Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble() : 0);
auctionedItem.setCurrentPrice(Settings.ROUND_ALL_PRICES.getBoolean() ? Math.round(this.isBiddingItem ? this.bidStartPrice : this.buyNowPrice <= -1 ? this.bidStartPrice : this.buyNowPrice) : this.isBiddingItem ? this.bidStartPrice : this.buyNowPrice <= -1 ? this.bidStartPrice : this.buyNowPrice);
auctionedItem.setListedWorld(e.player.getWorld().getName());
auctionedItem.setInfinite(false);
auctionedItem.setAllowPartialBuy(false);
AuctionHouse.getInstance().getGuiManager().showGUI(e.player, new GUIListingConfirm(e.player, auctionedItem, result -> {
if (!result) {
e.player.closeInventory();
if (!this.acceptsItems || this.itemToBeListed != null && this.itemToBeListed.getType() != XMaterial.AIR.parseMaterial())
PlayerUtils.giveItem(e.player, this.itemToBeListed);
return;
}
AuctionAPI.getInstance().listAuction(
e.player,
this.itemToBeListed.clone(),
this.itemToBeListed.clone(),
this.auctionTime,
/* buy now price */ this.isAllowingBuyNow ? this.buyNowPrice : -1,
/* start bid price */ isBiddingItem ? this.bidStartPrice : !this.isAllowingBuyNow ? this.buyNowPrice : 0,
/* bid inc price */ isBiddingItem ? this.bidIncrementPrice != null ? this.bidIncrementPrice : Settings.MIN_AUCTION_INCREMENT_PRICE.getDouble() : 0,
/* current price */ isBiddingItem ? this.bidStartPrice : this.buyNowPrice <= -1 ? this.bidStartPrice : this.buyNowPrice,
isBiddingItem || !this.isAllowingBuyNow,
false,
false,
false,
false
);
e.player.closeInventory();
e.player.closeInventory();
if (Settings.OPEN_MAIN_AUCTION_HOUSE_AFTER_MENU_LIST.getBoolean()) {
e.manager.showGUI(e.player, new GUIAuctionHouse(this.auctionPlayer));
}
}));
} else {
if (!this.auctionPlayer.canListItem()) {
return;

View File

@ -1,125 +0,0 @@
package ca.tweetzy.auctionhouse.guis.confirmation;
import ca.tweetzy.auctionhouse.AuctionHouse;
import ca.tweetzy.auctionhouse.api.AuctionAPI;
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
import ca.tweetzy.auctionhouse.auction.enums.AuctionStackType;
import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui;
import ca.tweetzy.auctionhouse.guis.GUIAuctionHouse;
import ca.tweetzy.auctionhouse.helpers.MaterialCategorizer;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.utils.TextUtils;
import ca.tweetzy.core.utils.items.TItemBuilder;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.util.Objects;
import java.util.UUID;
/**
* The current file has been created by Kiran Hart
* Date Created: March 17 2021
* Time Created: 11:18 p.m.
* Usage of any code found within this class is prohibited unless given explicit permission otherwise
*/
public class GUIConfirmListing extends AbstractPlaceholderGui {
private final Player player;
private final ItemStack originalItem;
private final ItemStack itemToSell;
private final int allowedTime;
private final Double basePrice;
private final Double startingBid;
private final Double bidIncrement;
private final boolean isBiddingItem;
private final boolean isBundle;
private final boolean requiresHandRemove;
private final boolean isInfinite;
private final AuctionedItem auctionedItem;
public GUIConfirmListing(Player player, ItemStack originalItem, ItemStack itemToSell, int allowedTime, double basePrice, double startingBid, double bidIncrement, boolean isBiddingItem, boolean bundle, boolean requiresHandRemove, boolean isInfinite) {
super(player);
this.player = player;
this.originalItem = originalItem;
this.itemToSell = itemToSell;
this.allowedTime = allowedTime;
this.basePrice = basePrice;
this.startingBid = startingBid;
this.bidIncrement = bidIncrement;
this.isBiddingItem = isBiddingItem;
this.isBundle = bundle;
this.requiresHandRemove = requiresHandRemove;
this.isInfinite = isInfinite;
this.auctionedItem = new AuctionedItem(
UUID.randomUUID(),
player.getUniqueId(),
player.getUniqueId(),
player.getName(),
player.getName(),
MaterialCategorizer.getMaterialCategory(this.originalItem),
this.itemToSell.clone(),
/* buy now price */ Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() ? this.basePrice : -1,
/* start bid price */ this.isBiddingItem ? this.startingBid : 0,
/* bid inc price */ this.isBiddingItem ? this.bidIncrement != null ? this.bidIncrement : 1 : 0,
/* current price */ this.isBiddingItem ? this.startingBid : this.basePrice <= -1 ? this.startingBid : this.basePrice,
this.isBiddingItem,
false,
System.currentTimeMillis() + (this.allowedTime * 1000L)
);
// todo add back if dupe is brought back to life
// 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);
draw();
}
private void placeAuctionItem() {
setItem(0, 4, this.auctionedItem.getDisplayStack(AuctionStackType.LISTING_PREVIEW));
}
private void draw() {
setItems(0, 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_CONFIRM_LISTING_YES_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_CONFIRM_LISTING_YES_NAME.getString()).setLore(Settings.GUI_CONFIRM_LISTING_YES_LORE.getStringList()).toItemStack());
placeAuctionItem();
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.exit();
e.player.getInventory().addItem(originalItem);
});
setActionForRange(0, 3, ClickType.LEFT, e -> {
AuctionHouse.getInstance().getAuctionPlayerManager().removeItemFromSellHolding(e.player.getUniqueId());
AuctionHouse.getInstance().getAuctionPlayerManager().removeFromUsingSellGUI(e.player.getUniqueId());
AuctionAPI.getInstance().listAuction(
this.player,
this.originalItem,
this.itemToSell,
this.allowedTime,
/* buy now price */ Settings.ALLOW_USAGE_OF_BUY_NOW_SYSTEM.getBoolean() ? this.basePrice : -1,
/* start bid price */ this.isBiddingItem ? this.startingBid : 0,
/* bid inc price */ this.isBiddingItem ? this.bidIncrement != null ? this.bidIncrement : 1 : 0,
/* current price */ this.isBiddingItem ? this.startingBid : this.basePrice <= -1 ? this.startingBid : this.basePrice,
this.isBiddingItem,
this.isBundle,
this.requiresHandRemove,
this.isInfinite,
false
);
if (Settings.OPEN_MAIN_AUCTION_HOUSE_AFTER_MENU_LIST.getBoolean()) {
e.manager.showGUI(e.player, new GUIAuctionHouse(AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(e.player.getUniqueId())));
} else {
e.gui.exit();
}
});
}
}

View File

@ -0,0 +1,64 @@
/*
* Auction House
* Copyright 2022 Kiran Hart
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package ca.tweetzy.auctionhouse.guis.confirmation;
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
import ca.tweetzy.auctionhouse.auction.enums.AuctionStackType;
import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui;
import ca.tweetzy.auctionhouse.settings.Settings;
import ca.tweetzy.core.utils.TextUtils;
import ca.tweetzy.core.utils.items.TItemBuilder;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import java.util.Objects;
import java.util.function.Consumer;
public final class GUIListingConfirm extends AbstractPlaceholderGui {
private final AuctionedItem auctionedItem;
private final Consumer<Boolean> result;
public GUIListingConfirm(Player player, AuctionedItem auctionedItem, Consumer<Boolean> result) {
super(player);
this.auctionedItem = auctionedItem;
this.result = result;
super.setTitle(TextUtils.formatText(Settings.GUI_CONFIRM_LISTING_TITLE.getString()));
setAcceptsItems(false);
setAllowClose(false);
setRows(1);
draw();
}
private void draw() {
setItems(0, 3, new TItemBuilder(Objects.requireNonNull(Settings.GUI_CONFIRM_LISTING_YES_ITEM.getMaterial().parseMaterial())).setName(Settings.GUI_CONFIRM_LISTING_YES_NAME.getString()).setLore(Settings.GUI_CONFIRM_LISTING_YES_LORE.getStringList()).toItemStack());
setItem(0, 4, this.auctionedItem.getDisplayStack(AuctionStackType.LISTING_PREVIEW));
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 -> {
setAllowClose(true);
this.result.accept(false);
});
setActionForRange(0, 3, ClickType.LEFT, e -> {
setAllowClose(true);
this.result.accept(true);
});
}
}