From f9c02791a1ab23960145f3d71b6b49bf19f01d71 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 3 Jun 2026 07:54:02 +0000 Subject: [PATCH 1/5] Handle cursor worth packet --- .../com/yourname/sellplugin/listener/WorthPacketListener.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/yourname/sellplugin/listener/WorthPacketListener.java b/src/main/java/com/yourname/sellplugin/listener/WorthPacketListener.java index dbf8c71..30fd6b8 100644 --- a/src/main/java/com/yourname/sellplugin/listener/WorthPacketListener.java +++ b/src/main/java/com/yourname/sellplugin/listener/WorthPacketListener.java @@ -46,6 +46,7 @@ public void register() { ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); packetListener = new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.SET_SLOT, + PacketType.Play.Server.SET_CURSOR_ITEM, PacketType.Play.Server.WINDOW_ITEMS) { @Override @@ -53,7 +54,8 @@ public void onPacketSending(PacketEvent event) { if (!WorthPacketListener.this.plugin.getConfigManager().isWorthEnabled()) return; if (!shouldDecorate(event.getPlayer())) return; - if (event.getPacketType() == PacketType.Play.Server.SET_SLOT) { + if (event.getPacketType() == PacketType.Play.Server.SET_SLOT + || event.getPacketType() == PacketType.Play.Server.SET_CURSOR_ITEM) { if (event.getPacket().getItemModifier().size() <= 0) return; ItemStack item = event.getPacket().getItemModifier().read(0); ItemStack updated = addWorthLore(event.getPlayer(), item); From 59cfedd7da659154fac6cabc8bada079e82a20f6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 4 Jun 2026 19:03:16 +0000 Subject: [PATCH 2/5] Revert category buttons to open sell confirm GUI instead of item prices --- src/main/java/com/yourname/sellplugin/gui/GUIListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/yourname/sellplugin/gui/GUIListener.java b/src/main/java/com/yourname/sellplugin/gui/GUIListener.java index bd86855..b4ae1cd 100644 --- a/src/main/java/com/yourname/sellplugin/gui/GUIListener.java +++ b/src/main/java/com/yourname/sellplugin/gui/GUIListener.java @@ -81,7 +81,7 @@ public void onClick(InventoryClickEvent e) { e.setCancelled(true); String catId = shopGUI.getCategoryAtSlot(slot); if (catId != null) { - new CategoryItemsGUI(plugin, player, catId, 0).open(player); + new ConfirmSellGUI(plugin, player, catId, 0).open(player); } return; } From c5e25294acf0d4a7e6371140b1763bbfc1914001 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 4 Jun 2026 19:06:10 +0000 Subject: [PATCH 3/5] Change category buttons to open CategoryProgressGUI (sell multi) --- src/main/java/com/yourname/sellplugin/gui/GUIListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/yourname/sellplugin/gui/GUIListener.java b/src/main/java/com/yourname/sellplugin/gui/GUIListener.java index b4ae1cd..a4c5896 100644 --- a/src/main/java/com/yourname/sellplugin/gui/GUIListener.java +++ b/src/main/java/com/yourname/sellplugin/gui/GUIListener.java @@ -81,7 +81,7 @@ public void onClick(InventoryClickEvent e) { e.setCancelled(true); String catId = shopGUI.getCategoryAtSlot(slot); if (catId != null) { - new ConfirmSellGUI(plugin, player, catId, 0).open(player); + new CategoryProgressGUI(plugin, player, catId).open(player); } return; } From eab2fc6e4bb68b07065c8c5554857a34c53ef6fb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Jun 2026 18:07:46 +0000 Subject: [PATCH 4/5] Fix POWDER_SNOW crash, creative mode worth lore bug, and add example-config auto-generation - Fix POWDER_SNOW to POWDER_SNOW_BUCKET in price.yml (POWDER_SNOW is a block-only material, not a valid item) - Add mat.isItem() safety check in CategoryItemsGUI.resolveItemStack to prevent similar crashes - Skip worth packet decoration for creative mode players to prevent lore getting baked into item NBT - Auto-generate example-config.yml from JAR defaults on startup and reload --- .../com/yourname/sellplugin/SellPlugin.java | 1 + .../sellplugin/gui/CategoryItemsGUI.java | 3 ++- .../listener/WorthPacketListener.java | 3 +++ .../sellplugin/manager/ConfigManager.java | 17 +++++++++++++++++ src/main/resources/price.yml | 2 +- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/yourname/sellplugin/SellPlugin.java b/src/main/java/com/yourname/sellplugin/SellPlugin.java index e766b20..edd886f 100644 --- a/src/main/java/com/yourname/sellplugin/SellPlugin.java +++ b/src/main/java/com/yourname/sellplugin/SellPlugin.java @@ -28,6 +28,7 @@ public class SellPlugin extends JavaPlugin { public void onEnable() { saveDefaultConfig(); configManager = new ConfigManager(this); + configManager.generateExampleConfig(); priceManager = new PriceManager(this); priceManager.loadPrices(); diff --git a/src/main/java/com/yourname/sellplugin/gui/CategoryItemsGUI.java b/src/main/java/com/yourname/sellplugin/gui/CategoryItemsGUI.java index a1c1848..32e21a3 100644 --- a/src/main/java/com/yourname/sellplugin/gui/CategoryItemsGUI.java +++ b/src/main/java/com/yourname/sellplugin/gui/CategoryItemsGUI.java @@ -223,7 +223,8 @@ private ItemStack resolveItemStack(String itemKey) { return item; } Material mat = Material.matchMaterial(itemKey); - return new ItemStack(mat != null ? mat : Material.BARRIER); + if (mat == null || !mat.isItem()) return new ItemStack(Material.BARRIER); + return new ItemStack(mat); } // ── Item clicked ───────────────────────────────────────────────────────── diff --git a/src/main/java/com/yourname/sellplugin/listener/WorthPacketListener.java b/src/main/java/com/yourname/sellplugin/listener/WorthPacketListener.java index 30fd6b8..714e62a 100644 --- a/src/main/java/com/yourname/sellplugin/listener/WorthPacketListener.java +++ b/src/main/java/com/yourname/sellplugin/listener/WorthPacketListener.java @@ -16,6 +16,7 @@ import com.yourname.sellplugin.gui.ShopMainGUI; import com.yourname.sellplugin.gui.TopSellGUI; import com.yourname.sellplugin.util.NumberFormatter; +import org.bukkit.GameMode; import org.bukkit.block.DoubleChest; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryType; @@ -113,6 +114,8 @@ private ItemStack addWorthLore(Player player, ItemStack original) { } private boolean shouldDecorate(Player player) { + if (player.getGameMode() == GameMode.CREATIVE) return false; + Inventory topInventory = player.getOpenInventory().getTopInventory(); InventoryHolder holder = topInventory.getHolder(); diff --git a/src/main/java/com/yourname/sellplugin/manager/ConfigManager.java b/src/main/java/com/yourname/sellplugin/manager/ConfigManager.java index b402892..6973963 100644 --- a/src/main/java/com/yourname/sellplugin/manager/ConfigManager.java +++ b/src/main/java/com/yourname/sellplugin/manager/ConfigManager.java @@ -224,6 +224,23 @@ public List getIconLore(String key, List defaultLore) { public void reload() { plugin.reloadConfig(); plugin.getPriceManager().loadPrices(); + generateExampleConfig(); + } + + /** + * Generates an example-config.yml in the plugin data folder that always + * reflects the latest defaults shipped inside the JAR. + */ + public void generateExampleConfig() { + try { + java.io.InputStream in = plugin.getResource("config.yml"); + if (in == null) return; + java.io.File target = new java.io.File(plugin.getDataFolder(), "example-config.yml"); + java.nio.file.Files.copy(in, target.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING); + in.close(); + } catch (java.io.IOException e) { + plugin.getLogger().warning("Could not generate example-config.yml: " + e.getMessage()); + } } // ---- Helpers ---------------------------------------------------------- diff --git a/src/main/resources/price.yml b/src/main/resources/price.yml index dad1d93..984dd25 100644 --- a/src/main/resources/price.yml +++ b/src/main/resources/price.yml @@ -68,7 +68,7 @@ armortools: FLINT_AND_STEEL: 6 ROCKET: 6 LEAD: 5 - POWDER_SNOW: 5 + POWDER_SNOW_BUCKET: 5 SHEARS: 4 SPYGLASS: 50 COMPASS: 10.0 From 386cd52a47f6cc4fa8d5389733714c36ee19b102 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 13 Jun 2026 08:21:52 +0000 Subject: [PATCH 5/5] Fix non-dyed shulker box not recognized as shulker box --- .../java/com/yourname/sellplugin/manager/SellManager.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/yourname/sellplugin/manager/SellManager.java b/src/main/java/com/yourname/sellplugin/manager/SellManager.java index d7a9a00..23ad77d 100644 --- a/src/main/java/com/yourname/sellplugin/manager/SellManager.java +++ b/src/main/java/com/yourname/sellplugin/manager/SellManager.java @@ -307,9 +307,11 @@ public void sendSellNotification(Player player, double amount, int itemCount) { // Shulker box helpers // --------------------------------------------------------------- - /** Returns true if the item is any colour of shulker box. */ + /** Returns true if the item is any colour of shulker box (including the non-dyed SHULKER_BOX). */ public static boolean isShulkerBox(ItemStack item) { - return item != null && item.getType().name().endsWith("_SHULKER_BOX"); + if (item == null) return false; + String name = item.getType().name(); + return name.equals("SHULKER_BOX") || name.endsWith("_SHULKER_BOX"); } /**