From f4f1c942b008bcbd437c9dcd7ba2898fd44698e8 Mon Sep 17 00:00:00 2001 From: Kiran Hart Date: Wed, 29 Mar 2023 00:55:55 -0400 Subject: [PATCH] adjust order for dealing with confirm listing death return Took 13 minutes --- .../auctionhouse/guis/confirmation/GUIListingConfirm.java | 8 +++++++- .../tweetzy/auctionhouse/listeners/PlayerListeners.java | 7 +++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIListingConfirm.java b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIListingConfirm.java index 693c73e..f3113ee 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIListingConfirm.java +++ b/src/main/java/ca/tweetzy/auctionhouse/guis/confirmation/GUIListingConfirm.java @@ -26,6 +26,7 @@ import ca.tweetzy.auctionhouse.guis.AbstractPlaceholderGui; import ca.tweetzy.auctionhouse.settings.Settings; import ca.tweetzy.core.utils.PlayerUtils; import ca.tweetzy.core.utils.TextUtils; +import ca.tweetzy.flight.comp.enums.CompMaterial; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.metadata.FixedMetadataValue; @@ -59,7 +60,6 @@ public final class GUIListingConfirm extends AbstractPlaceholderGui { }); setOnClose(close -> { - close.player.removeMetadata("AuctionHouseConfirmListing", AuctionHouse.getInstance()); final AuctionPlayer auctionPlayer = AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(close.player.getUniqueId()); if (auctionPlayer.getItemBeingListed() != null) { @@ -67,6 +67,7 @@ public final class GUIListingConfirm extends AbstractPlaceholderGui { auctionPlayer.setItemBeingListed(null); } + close.player.removeMetadata("AuctionHouseConfirmListing", AuctionHouse.getInstance()); AuctionHouse.getInstance().getAuctionPlayerManager().processSell(close.player); }); @@ -85,8 +86,13 @@ public final class GUIListingConfirm extends AbstractPlaceholderGui { resulted.add(e.player.getUniqueId()); setAllowClose(true); + final AuctionPlayer auctionPlayer = AuctionHouse.getInstance().getAuctionPlayerManager().getPlayer(e.player.getUniqueId()); + auctionPlayer.setItemBeingListed(CompMaterial.AIR.parseItem()); + this.result.accept(false); }); + + setActionForRange(0, 3, ClickType.LEFT, e -> { if (resulted.contains(e.player.getUniqueId())) return; resulted.add(e.player.getUniqueId()); diff --git a/src/main/java/ca/tweetzy/auctionhouse/listeners/PlayerListeners.java b/src/main/java/ca/tweetzy/auctionhouse/listeners/PlayerListeners.java index f8b1e71..23431b0 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/listeners/PlayerListeners.java +++ b/src/main/java/ca/tweetzy/auctionhouse/listeners/PlayerListeners.java @@ -71,8 +71,11 @@ public class PlayerListeners implements Listener { Bukkit.getServer().getScheduler().cancelTask(auctionPlayer.getAssignedTaskId()); if (auctionPlayer.getItemBeingListed() != null && player.getLocation().getWorld() != null) { - if (!AuctionHouse.getInstance().getAuctionPlayerManager().isInSellProcess(player)) - player.getLocation().getWorld().dropItemNaturally(player.getLocation(), auctionPlayer.getItemBeingListed()); + if (!AuctionHouse.getInstance().getAuctionPlayerManager().isInSellProcess(player)) { + + if (!player.hasMetadata("AuctionHouseConfirmListing")) + player.getLocation().getWorld().dropItemNaturally(player.getLocation(), auctionPlayer.getItemBeingListed()); + } auctionPlayer.setItemBeingListed(CompMaterial.AIR.parseItem()); } }