Fix some NPE caused by null itemstacks

This commit is contained in:
Len committed 2024-08-04 20:59:45 +02:00
1 parent 633bc97abb
commit 7d9cb418af
3 files changed
+6 -4

No files matched your search

@@ -313,7 +313,7 @@ public class PlayerShop {
}
private TransactionError executeGambleTransaction(Player player) {
ItemStack itemStack = getRandomItem();
ItemStack itemStack = getItemStack();
if (itemStack == null)
return TransactionError.INSUFFICIENT_FUNDS_SHOP;
@@ -419,9 +419,11 @@ public class PlayerShop {
transactions.add(transaction);
}
private ItemStack getRandomItem() {
public ItemStack getItemStack() {
if (!isInitialized())
return null;
if (this.getType() != ShopType.GAMBLE)
return itemStack;
if (this.getInventory().isEmpty())
return null;
ArrayList<ItemStack> contents = new ArrayList<>();