From 7f4618ec16ced324d1bb4c118de544fae53d7277 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sat, 26 Sep 2020 20:55:42 +0200 Subject: [PATCH] Fixed Colors for 1.12 --- .../src/de/steamwar/inventory/SWItem.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java b/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java index d77ffab..f75b0b2 100644 --- a/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java +++ b/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java @@ -116,6 +116,10 @@ public class SWItem { this(material, (byte)0, name, new ArrayList<>(), false, null); } + public SWItem(Material material, byte meta, String name){ + this(material, meta, name, new ArrayList<>(), false, null); + } + public SWItem(Material material, String name, List lore, boolean enchanted, InvCallback c) { this(material, (byte)0, name, lore, enchanted, c); } @@ -142,7 +146,13 @@ public class SWItem { public static SWItem getItemFromJson(JsonObject itemJson) { SWItem item = null; try { - item = new SWItem(Material.valueOf(itemJson.get("material").getAsString()), itemJson.get("title").getAsString()); + if(itemJson.has("color")) { + item = new SWItem(SWItem.getDye(itemJson.get("color").getAsInt()), + itemJson.has("color")?itemJson.get("color").getAsByte():0, + itemJson.get("title").getAsString()); + }else { + item = new SWItem(Material.valueOf(itemJson.get("material").getAsString()), itemJson.get("title").getAsString()); + } }catch (IllegalArgumentException e) { item = new SWItem(Material.STONE, itemJson.get("title").getAsString()); } @@ -150,9 +160,7 @@ public class SWItem { item = SWItem.getPlayerSkull(itemJson.get("skullOwner").getAsString()); item.setName(itemJson.get("title").getAsString()); } - if(itemJson.has("color")) { - item.getItemStack().setType(SWItem.getDye(itemJson.get("color").getAsInt())); - } + if(itemJson.has("enchanted")) item.setEnchanted(true); if(itemJson.has("lore")) {