diff --git a/common/src/main/java/me/lojosho/hibiscuscommons/config/serializer/ItemSerializer.java b/common/src/main/java/me/lojosho/hibiscuscommons/config/serializer/ItemSerializer.java index d408fcf..e35f41d 100644 --- a/common/src/main/java/me/lojosho/hibiscuscommons/config/serializer/ItemSerializer.java +++ b/common/src/main/java/me/lojosho/hibiscuscommons/config/serializer/ItemSerializer.java @@ -81,11 +81,8 @@ public class ItemSerializer implements TypeSerializer { if (itemMeta == null) return item; if (!nameNode.virtual()) { - if (HibiscusCommonsPlugin.isOnPaper()) { - itemMeta.displayName(AdventureUtils.MINI_MESSAGE.deserialize(nameNode.getString(""))); - } else { - itemMeta.setDisplayName(StringUtils.parseStringToString(nameNode.getString(""))); - } + if (HibiscusCommonsPlugin.isOnPaper()) itemMeta.displayName(AdventureUtils.MINI_MESSAGE.deserialize(nameNode.getString(""))); + else itemMeta.setDisplayName(StringUtils.parseStringToString(nameNode.getString(""))); } if (!unbreakableNode.virtual()) itemMeta.setUnbreakable(unbreakableNode.getBoolean()); if (!glowingNode.virtual()) { @@ -93,13 +90,12 @@ public class ItemSerializer implements TypeSerializer { itemMeta.addEnchant(Enchantment.LUCK, 1, true); } if (!loreNode.virtual()) { - if (HibiscusCommonsPlugin.isOnPaper()) { + if (HibiscusCommonsPlugin.isOnPaper()) itemMeta.lore(loreNode.getList(String.class, new ArrayList<>()). stream().map(AdventureUtils.MINI_MESSAGE::deserialize).collect(Collectors.toList())); - } else { - itemMeta.setLore(loreNode.getList(String.class, new ArrayList<>()). + else itemMeta.setLore(loreNode.getList(String.class, new ArrayList<>()). stream().map(StringUtils::parseStringToString).collect(Collectors.toList())); - } + } if (!modelDataNode.virtual()) itemMeta.setCustomModelData(modelDataNode.getInt()); @@ -113,13 +109,13 @@ public class ItemSerializer implements TypeSerializer { for (ConfigurationNode enchantNode : enchantsNode.childrenMap().values()) { String enchantName = enchantNode.key().toString().toLowerCase(); NamespacedKey key = NamespacedKey.minecraft(enchantName); - Enchantment enchant = Enchantment.getByKey(key); + Enchantment enchant = Registry.ENCHANTMENT.get(key); if (enchant == null) continue; itemMeta.addEnchant(enchant, enchantNode.getInt(1), true); } } - try { + if (!itemFlagsNode.virtual()) { for (String itemFlag : itemFlagsNode.getList(String.class)) { if (!EnumUtils.isValidEnum(ItemFlag.class, itemFlag)) continue; @@ -127,9 +123,6 @@ public class ItemSerializer implements TypeSerializer { itemMeta.addItemFlags(ItemFlag.valueOf(itemFlag)); } } - } catch (Exception e) { - e.printStackTrace(); - } if (item.getType() == Material.PLAYER_HEAD) { SkullMeta skullMeta = (SkullMeta) itemMeta; @@ -150,7 +143,7 @@ public class ItemSerializer implements TypeSerializer { skullMeta.getPersistentDataContainer().set(InventoryUtils.getSkullTexture(), PersistentDataType.STRING, textureString); } // Decodes the texture string and sets the texture url to the skull - PlayerProfile profile = Bukkit.createPlayerProfile(UUID.randomUUID()); + PlayerProfile profile = Bukkit.createProfile(UUID.randomUUID()); PlayerTextures textures = profile.getTextures(); String decoded = new String(Base64.getDecoder().decode(textureString)); @@ -166,7 +159,6 @@ public class ItemSerializer implements TypeSerializer { skullMeta.setOwnerProfile(profile); } } - itemMeta = skullMeta; } if (!colorNode.virtual()) { @@ -186,6 +178,5 @@ public class ItemSerializer implements TypeSerializer { public void serialize(final Type type, @Nullable final ItemStack obj, final ConfigurationNode node) throws SerializationException { } - }