From d815729b6f16a1003703ab4b024c8306037ce8ef Mon Sep 17 00:00:00 2001 From: MrUnicorn <39692316+MrUnic0rn0@users.noreply.github.com> Date: Tue, 11 Jan 2022 15:04:46 +0100 Subject: [PATCH] Add CustomModelData option for itemInfo(ItemStack is) Add support of the CustomModelData for ItemStack in itemInfo(ItemStack is) Add private static int getItemCustomModelData(ItemStack is) to get the customModelData of an item (default return 0) --- .../gmail/St3venAU/plugins/ArmorStandTools/Utils.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/Utils.java b/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/Utils.java index d6498ae..907f964 100644 --- a/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/Utils.java +++ b/src/main/java/com/gmail/St3venAU/plugins/ArmorStandTools/Utils.java @@ -166,6 +166,11 @@ class Utils { } return tags.length() == 0 ? "" : tags.toString(); } + + static private int getItemCustomModelData(ItemStack is) { + if(is == null || is.getItemMeta() == null || is.getItemMeta().getCustomModelData() == null) return 0; + return is.getItemMeta().getCustomModelData(); + } static private String skullOwner(ItemStack is) { if(is == null || is.getItemMeta() == null || !(is.getItemMeta() instanceof SkullMeta skull)) return ""; @@ -187,6 +192,7 @@ class Utils { @SuppressWarnings("deprecation") short durability = is.getDurability(); String skullOwner = skullOwner(is); + int customModelData = getItemCustomModelData(is); int n = 0; if(itemStackTags.length() > 0 || durability > 0 || skullOwner.length() > 0) { sb.append(",tag:{"); @@ -194,6 +200,11 @@ class Utils { sb.append("Damage:").append(durability); n++; } + if(customModelData > 0) { + if(n > 0) sb.append(","); + sb.append("CustomModelData:").append(customModelData); + n++; + } if(itemStackTags.length() > 0) { if(n > 0) sb.append(","); sb.append(itemStackTags);