Add helper method to get shop item type.

This commit is contained in:
Len 2026-08-06 09:04:30 -05:00
parent 11c5c69dc7
commit c209e0098a
2 changed files with 14 additions and 4 deletions

View File

@ -218,7 +218,7 @@ public class ShopHandler {
continue; continue;
} }
Material material = shop.getItemStack().getType(); Material material = shop.getShopItemType();
List<PlayerShop> shopList = shopByMaterialTreeSet.computeIfAbsent(material, v -> new ArrayList<>()); List<PlayerShop> shopList = shopByMaterialTreeSet.computeIfAbsent(material, v -> new ArrayList<>());
shopList.add(shop); shopList.add(shop);
} }

View File

@ -433,12 +433,15 @@ public class PlayerShop {
} }
public ItemStack getItemStack() { public ItemStack getItemStack() {
if (!isInitialized()) if (!isInitialized()) {
return null; return null;
if (this.getType() != ShopType.RANDOM) }
if (this.getType() != ShopType.RANDOM) {
return itemStack; return itemStack;
if (this.getInventory().isEmpty()) }
if (this.getInventory() == null) {
return null; return null;
}
ArrayList<ItemStack> contents = new ArrayList<>(); ArrayList<ItemStack> contents = new ArrayList<>();
for (ItemStack it : this.getInventory().getContents()) { for (ItemStack it : this.getInventory().getContents()) {
if (it != null) { if (it != null) {
@ -487,4 +490,11 @@ public class PlayerShop {
return component; return component;
} }
public Material getShopItemType() {
if (this.type == ShopType.RANDOM) {
return Material.STRUCTURE_VOID; // TODO -- Load from config
}
return itemStack.getType();
}
} }