From 00a02ca9c00cde0bdc1ddae771b7be9029ad7d74 Mon Sep 17 00:00:00 2001 From: Ghost_chu <2908803755@qq.com> Date: Mon, 3 Jun 2019 23:37:40 +0800 Subject: [PATCH] Fix NPE Former-commit-id: 37d12f83111e6209a14de0727ee5d03a0eb18b34 [formerly 4760f41e01ff7e51a38d341fe1c2d9dfc9db8693] Former-commit-id: ff187c180a0c62f351e3bcae32651244ee066af2 --- .../maxgamer/quickshop/Listeners/DisplayProtectionListener.java | 2 +- src/main/java/org/maxgamer/quickshop/Shop/DisplayItem.java | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/DisplayProtectionListener.java b/src/main/java/org/maxgamer/quickshop/Listeners/DisplayProtectionListener.java index d5a2b7cae..09734052d 100644 --- a/src/main/java/org/maxgamer/quickshop/Listeners/DisplayProtectionListener.java +++ b/src/main/java/org/maxgamer/quickshop/Listeners/DisplayProtectionListener.java @@ -49,7 +49,7 @@ public class DisplayProtectionListener implements Listener { // } catch (Exception e) {} // } - for (ItemStack is : event.getInventory().getContents()) { + for (ItemStack is : event.getInventory().getStorageContents()) { if (itemStackCheck(is)) { is.setType(Material.AIR); is.setAmount(1); diff --git a/src/main/java/org/maxgamer/quickshop/Shop/DisplayItem.java b/src/main/java/org/maxgamer/quickshop/Shop/DisplayItem.java index 97eb41ce5..e0045b5ff 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/DisplayItem.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/DisplayItem.java @@ -50,6 +50,8 @@ public interface DisplayItem { public static boolean checkShopItem(ItemStack itemStack) { + if (itemStack == null) + return false; if (!itemStack.hasItemMeta()) { return false; }