diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellAuction.java b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellAuction.java index c25ea31..693ded6 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellAuction.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellAuction.java @@ -41,6 +41,7 @@ import ca.tweetzy.core.utils.nms.NBTEditor; import lombok.NonNull; import org.bukkit.ChatColor; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import java.util.Arrays; import java.util.HashMap; @@ -70,10 +71,14 @@ public final class GUISellAuction extends AbstractPlaceholderGui { setRows(6); setOnClose(close -> { - if (BundleUtil.isBundledItem(this.auctionPlayer.getItemBeingListed())) - PlayerUtils.giveItem(close.player, BundleUtil.extractBundleItems(this.auctionPlayer.getItemBeingListed())); - else - PlayerUtils.giveItem(close.player, this.auctionPlayer.getItemBeingListed()); + final ItemStack itemToGive = this.auctionPlayer.getItemBeingListed(); + if (itemToGive != null) + + if (BundleUtil.isBundledItem(itemToGive)) { + PlayerUtils.giveItem(close.player, BundleUtil.extractBundleItems(itemToGive)); + } else { + PlayerUtils.giveItem(close.player, itemToGive); + } this.auctionPlayer.setItemBeingListed(null); }); diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellBin.java b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellBin.java index d17c5e2..e05181d 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellBin.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/sell/GUISellBin.java @@ -41,6 +41,7 @@ import ca.tweetzy.core.utils.nms.NBTEditor; import lombok.NonNull; import org.bukkit.ChatColor; import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; import java.util.Arrays; import java.util.HashMap; @@ -66,10 +67,14 @@ public final class GUISellBin extends AbstractPlaceholderGui { setRows(6); setOnClose(close -> { - if (BundleUtil.isBundledItem(this.auctionPlayer.getItemBeingListed())) PlayerUtils.giveItem(close.player, BundleUtil.extractBundleItems(this.auctionPlayer.getItemBeingListed())); - else { - PlayerUtils.giveItem(close.player, this.auctionPlayer.getItemBeingListed()); - } + final ItemStack itemToGive = this.auctionPlayer.getItemBeingListed(); + if (itemToGive != null) + + if (BundleUtil.isBundledItem(itemToGive)) { + PlayerUtils.giveItem(close.player, BundleUtil.extractBundleItems(itemToGive)); + } else { + PlayerUtils.giveItem(close.player, itemToGive); + } this.auctionPlayer.setItemBeingListed(null); @@ -166,7 +171,7 @@ public final class GUISellBin extends AbstractPlaceholderGui { setItem(1, 4, createListingItem().getDisplayStack(AuctionStackType.LISTING_PREVIEW)); - setButton(getRows() - 1, 4, ConfigurationItemHelper.createConfigurationItem(this.player, + setButton(getRows() - 1, 4, ConfigurationItemHelper.createConfigurationItem(this.player, Settings.GUI_SELL_BIN_ITEM_ITEMS_CONTINUE_ITEM.getString(), Settings.GUI_SELL_BIN_ITEM_ITEMS_CONTINUE_NAME.getString(), Settings.GUI_SELL_BIN_ITEM_ITEMS_CONTINUE_LORE.getStringList(), @@ -213,7 +218,7 @@ public final class GUISellBin extends AbstractPlaceholderGui { private void drawQtyPurchase() { if (Settings.ALLOW_PURCHASE_OF_SPECIFIC_QUANTITIES.getBoolean()) { - setButton(3, 7, ConfigurationItemHelper.createConfigurationItem(this.player, + setButton(3, 7, ConfigurationItemHelper.createConfigurationItem(this.player, this.allowPartialBuy ? Settings.GUI_SELL_BIN_ITEM_ITEMS_PARTIAL_ENABLED_ITEM.getString() : Settings.GUI_SELL_BIN_ITEM_ITEMS_PARTIAL_DISABLED_ITEM.getString(), this.allowPartialBuy ? Settings.GUI_SELL_BIN_ITEM_ITEMS_PARTIAL_ENABLED_NAME.getString() : Settings.GUI_SELL_BIN_ITEM_ITEMS_PARTIAL_DISABLED_NAME.getString(), this.allowPartialBuy ? Settings.GUI_SELL_BIN_ITEM_ITEMS_PARTIAL_ENABLED_LORE.getStringList() : Settings.GUI_SELL_BIN_ITEM_ITEMS_PARTIAL_DISABLED_LORE.getStringList(), diff --git a/src/main/java/ca/tweetzy/auctionhouse/listeners/PlayerListeners.java b/src/main/java/ca/tweetzy/auctionhouse/listeners/PlayerListeners.java index 5edc420..650f539 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/listeners/PlayerListeners.java +++ b/src/main/java/ca/tweetzy/auctionhouse/listeners/PlayerListeners.java @@ -108,7 +108,14 @@ public class PlayerListeners implements Listener { if (instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()) != null && instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()).getItemBeingListed() != null) { - player.getInventory().addItem(instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()).getItemBeingListed()); + final ItemStack toGiveRaw = instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()).getItemBeingListed(); + + if (BundleUtil.isBundledItem(toGiveRaw)) { + PlayerUtils.giveItem(player, BundleUtil.extractBundleItems(toGiveRaw)); + } else { + PlayerUtils.giveItem(player, toGiveRaw); + } + instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()).setItemBeingListed(null); instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()).setPlayer(null); }