Fix some NPE caused by null itemstacks
This commit is contained in:
parent
633bc97abb
commit
7d9cb418af
|
|
@ -55,7 +55,7 @@ public class ListShopsGui extends AbstractGui {
|
|||
for (int i = startIndex; i < shops.size(); i++) {
|
||||
PlayerShop shop = shops.get(i);
|
||||
ItemStack item = shop.getItemStack();
|
||||
if (!shop.isInitialized())
|
||||
if (!shop.isInitialized() || item == null)
|
||||
item = GuiIcon.EMPTY_SHOP.getItemStack();
|
||||
|
||||
if (!addItem(item)) {
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ public class TransactionListener extends EventListener {
|
|||
TagResolver placeholders = TagResolver.resolver(action,
|
||||
Placeholder.parsed("amount", "" + playerShop.getAmount()),
|
||||
Placeholder.component("item", ShopUtil.itemNameComponent(playerShop.getItemStack())),
|
||||
Placeholder.parsed("material", Util.capitalize(playerShop.getItemStack().getType().name())),
|
||||
Placeholder.component("material", ShopUtil.trimmedItemNameComponent(playerShop.getItemStack())),
|
||||
Placeholder.parsed("price", "" + ShopUtil.round(playerShop.getPrice()))
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -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<>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user