📦 when closing the sell menu (auction/bin) with a bundled listing, if the action was to rejoin, it will give the player the extracted bundle.

Took 3 minutes
This commit is contained in:
Kiran Hart 2023-06-06 17:47:31 -04:00
parent 6071bad99a
commit 491c8ec4a8
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
3 changed files with 28 additions and 11 deletions

View File

@ -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);
});

View File

@ -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(),

View File

@ -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);
}