From c209e0098a59fab9647f1991da31369f17fda857 Mon Sep 17 00:00:00 2001 From: Len <40720638+destro174@users.noreply.github.com> Date: Thu, 6 Aug 2026 09:04:30 -0500 Subject: [PATCH] Add helper method to get shop item type. --- .../alttd/playershops/handler/ShopHandler.java | 2 +- .../com/alttd/playershops/shop/PlayerShop.java | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/alttd/playershops/handler/ShopHandler.java b/src/main/java/com/alttd/playershops/handler/ShopHandler.java index 381e606..fed8c7f 100644 --- a/src/main/java/com/alttd/playershops/handler/ShopHandler.java +++ b/src/main/java/com/alttd/playershops/handler/ShopHandler.java @@ -218,7 +218,7 @@ public class ShopHandler { continue; } - Material material = shop.getItemStack().getType(); + Material material = shop.getShopItemType(); List shopList = shopByMaterialTreeSet.computeIfAbsent(material, v -> new ArrayList<>()); shopList.add(shop); } diff --git a/src/main/java/com/alttd/playershops/shop/PlayerShop.java b/src/main/java/com/alttd/playershops/shop/PlayerShop.java index 51c935e..1b3e0cf 100644 --- a/src/main/java/com/alttd/playershops/shop/PlayerShop.java +++ b/src/main/java/com/alttd/playershops/shop/PlayerShop.java @@ -433,12 +433,15 @@ public class PlayerShop { } public ItemStack getItemStack() { - if (!isInitialized()) + if (!isInitialized()) { return null; - if (this.getType() != ShopType.RANDOM) + } + if (this.getType() != ShopType.RANDOM) { return itemStack; - if (this.getInventory().isEmpty()) + } + if (this.getInventory() == null) { return null; + } ArrayList contents = new ArrayList<>(); for (ItemStack it : this.getInventory().getContents()) { if (it != null) { @@ -487,4 +490,11 @@ public class PlayerShop { return component; } + + public Material getShopItemType() { + if (this.type == ShopType.RANDOM) { + return Material.STRUCTURE_VOID; // TODO -- Load from config + } + return itemStack.getType(); + } }