mirror of
https://github.com/kiranhart/Auction-House.git
synced 2025-01-07 12:47:36 +01:00
🪲 Fixed bug where when cancelling a listing confirmation for bundled items, it will give the bundle item rather than the individual items
Took 16 minutes
This commit is contained in:
parent
b20443feff
commit
7c49d17d16
@ -20,6 +20,7 @@ package ca.tweetzy.auctionhouse.guis;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.ahv3.api.ListingResult;
|
||||
import ca.tweetzy.auctionhouse.ahv3.model.BundleUtil;
|
||||
import ca.tweetzy.auctionhouse.api.AuctionAPI;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
|
||||
@ -128,11 +129,17 @@ public final class GUIBundleCreation extends AbstractPlaceholderGui {
|
||||
auctionedItem.setInfinite(false);
|
||||
auctionedItem.setAllowPartialBuy(false);
|
||||
|
||||
auctionPlayer.setItemBeingListed(bundle);
|
||||
|
||||
if (Settings.ASK_FOR_LISTING_CONFIRMATION.getBoolean()) {
|
||||
instance.getGuiManager().showGUI(auctionPlayer.getPlayer(), new GUIListingConfirm(auctionPlayer.getPlayer(), auctionedItem, result -> {
|
||||
if (!result) {
|
||||
auctionPlayer.getPlayer().closeInventory();
|
||||
PlayerUtils.giveItem(auctionPlayer.getPlayer(), auctionedItem.getItem());
|
||||
|
||||
if (BundleUtil.isBundledItem(auctionedItem.getItem())) PlayerUtils.giveItem(auctionPlayer.getPlayer(), BundleUtil.extractBundleItems(auctionedItem.getItem()));
|
||||
else PlayerUtils.giveItem(auctionPlayer.getPlayer(), auctionedItem.getItem());
|
||||
|
||||
|
||||
auctionPlayer.setItemBeingListed(null);
|
||||
return;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@
|
||||
package ca.tweetzy.auctionhouse.guis.confirmation;
|
||||
|
||||
import ca.tweetzy.auctionhouse.AuctionHouse;
|
||||
import ca.tweetzy.auctionhouse.ahv3.model.BundleUtil;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionPlayer;
|
||||
import ca.tweetzy.auctionhouse.auction.AuctionedItem;
|
||||
import ca.tweetzy.auctionhouse.auction.enums.AuctionStackType;
|
||||
@ -63,7 +64,11 @@ public final class GUIListingConfirm extends AbstractPlaceholderGui {
|
||||
final AuctionPlayer auctionPlayer = AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(close.player.getUniqueId());
|
||||
|
||||
if (auctionPlayer.getItemBeingListed() != null) {
|
||||
PlayerUtils.giveItem(close.player, auctionedItem.getItem());
|
||||
if (BundleUtil.isBundledItem(auctionedItem.getItem())) PlayerUtils.giveItem(close.player, BundleUtil.extractBundleItems(auctionedItem.getItem()));
|
||||
else {
|
||||
PlayerUtils.giveItem(close.player, auctionedItem.getItem());
|
||||
}
|
||||
|
||||
auctionPlayer.setItemBeingListed(null);
|
||||
}
|
||||
|
||||
|
@ -26,9 +26,12 @@ import ca.tweetzy.auctionhouse.auction.enums.AuctionSaleType;
|
||||
import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui;
|
||||
import ca.tweetzy.auctionhouse.helpers.ConfigurationItemHelper;
|
||||
import ca.tweetzy.auctionhouse.settings.Settings;
|
||||
import ca.tweetzy.core.compatibility.XMaterial;
|
||||
import ca.tweetzy.core.gui.events.GuiClickEvent;
|
||||
import ca.tweetzy.core.utils.PlayerUtils;
|
||||
import lombok.NonNull;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -58,6 +61,8 @@ public final class GUISellPlaceItem extends AbstractPlaceholderGui {
|
||||
if (viewMode == ViewMode.SINGLE_ITEM) {
|
||||
setUnlocked(1, 4);
|
||||
setItem(1, 4, AIR);
|
||||
|
||||
|
||||
} else {
|
||||
setUnlockedRange(0, 35);
|
||||
setItems(0, 35, AIR);
|
||||
@ -65,9 +70,24 @@ public final class GUISellPlaceItem extends AbstractPlaceholderGui {
|
||||
|
||||
setOnClose(close -> gatherSellableItems().forEach(item -> PlayerUtils.giveItem(close.player, item)));
|
||||
|
||||
setPlayerInventoryAction(this::handleBlockedItemClick);
|
||||
setDefaultAction(click -> {
|
||||
if (click.clickType == ClickType.NUMBER_KEY)
|
||||
click.event.setCancelled(true);
|
||||
});
|
||||
|
||||
draw();
|
||||
}
|
||||
|
||||
private void handleBlockedItemClick(GuiClickEvent click) {
|
||||
final ItemStack clicked = click.clickedItem;
|
||||
if (clicked == null || clicked.getType() == XMaterial.AIR.parseMaterial()) return;
|
||||
|
||||
if (!AuctionAPI.getInstance().meetsListingRequirements(click.player, clicked)) {
|
||||
click.event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void draw() {
|
||||
|
||||
setButton(getRows() - 1, 0, getBackButtonItem(), click -> {
|
||||
|
Loading…
Reference in New Issue
Block a user