From 5076ef955b5cc12acd28e61a139a89573ef46550 Mon Sep 17 00:00:00 2001 From: MoBrot <90271578+MoBrot@users.noreply.github.com> Date: Thu, 21 Jul 2022 12:43:59 +0200 Subject: [PATCH] SWItem.getMaterial can not be null --- .../src/de/steamwar/inventory/SWItem.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java b/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java index b66d610..d9f9c23 100644 --- a/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java +++ b/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java @@ -51,7 +51,11 @@ public class SWItem { public static Material getMaterial(String material){ try{ - return FlatteningWrapper.impl.getMaterial(material); + Material m = FlatteningWrapper.impl.getMaterial(material); + if(m == null) + return Material.BARRIER; + + return m; }catch(IllegalArgumentException e){ return Material.STONE; } @@ -90,14 +94,10 @@ public class SWItem { @SuppressWarnings("deprecation") public SWItem(Material material, byte meta, String name, List lore, boolean enchanted, InvCallback c) { - if(material != null) { - try { - itemStack = new ItemStack(material, 1, (short) 0, meta); - } catch (IllegalArgumentException e) { - itemStack = new ItemStack(material, 1); - } - }else { - itemStack = new ItemStack(Material.BARRIER, 1); + try { + itemStack = new ItemStack(material, 1, (short)0, meta); + } catch (IllegalArgumentException e) { + itemStack = new ItemStack(material, 1); } itemMeta = itemStack.getItemMeta();