Fix some NPE caused by null itemstacks

This commit is contained in:
Len
2024-08-04 20:59:45 +02:00
parent 633bc97abb
commit 7d9cb418af
3 changed files with 6 additions and 4 deletions
@@ -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<>();