From 05138dc6cc86ef10d55514c69a6cf16959a0f506 Mon Sep 17 00:00:00 2001 From: Kiran Hart Date: Fri, 18 Nov 2022 10:45:48 -0500 Subject: [PATCH] fix player "crash" and leave, to use new listing item (give item back if they leave or crash), same with death Took 45 seconds --- .../ca/tweetzy/auctionhouse/listeners/PlayerListeners.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/ca/tweetzy/auctionhouse/listeners/PlayerListeners.java b/src/main/java/ca/tweetzy/auctionhouse/listeners/PlayerListeners.java index 18cc28e..355b318 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/listeners/PlayerListeners.java +++ b/src/main/java/ca/tweetzy/auctionhouse/listeners/PlayerListeners.java @@ -49,7 +49,6 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.inventory.CraftingInventory; -import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.persistence.PersistentDataType; @@ -96,6 +95,12 @@ public class PlayerListeners implements Listener { public void onPlayerQuit(PlayerQuitEvent e) { final Player player = e.getPlayer(); final AuctionHouse instance = AuctionHouse.getInstance(); + + if (instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()) != null) + if (instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()).getItemBeingListed() != null) + player.getInventory().addItem(instance.getAuctionPlayerManager().getPlayer(player.getUniqueId()).getItemBeingListed()); + + instance.getAuctionPlayerManager().getSellHolding().remove(player.getUniqueId()); instance.getLogger().info("Removing sell holding instance for user: " + player.getName()); }