From 9f229bbf6a7b13109c1e5e9a726451c81e33820c Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 5 Jun 2017 13:31:47 +0200 Subject: [PATCH] Fixed NPE when player does not have an item in his hand --- .../java/de/epiceric/shopchest/utils/Utils.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/java/de/epiceric/shopchest/utils/Utils.java b/src/main/java/de/epiceric/shopchest/utils/Utils.java index 3fcef13..aba1f9f 100644 --- a/src/main/java/de/epiceric/shopchest/utils/Utils.java +++ b/src/main/java/de/epiceric/shopchest/utils/Utils.java @@ -270,16 +270,18 @@ public class Utils { return true; } - if (item.getDurability() == 0) { - if (player.hasPermission(Permissions.CREATE + "." + item.getType().toString())) { + if (item != null) { + if (item.getDurability() == 0) { + if (player.hasPermission(Permissions.CREATE + "." + item.getType().toString())) { + return true; + } + } + + if (player.hasPermission(Permissions.CREATE + "." + item.getType().toString() + "." + item.getDurability())) { return true; } } - if (player.hasPermission(Permissions.CREATE + "." + item.getType().toString() + "." + item.getDurability())) { - return true; - } - return false; }