3
0
Mirror von https://github.com/St3venAU/ArmorStandTools.git synchronisiert 2024-12-27 12:00:07 +01:00

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)
Dieser Commit ist enthalten in:
MrUnicorn 2022-01-11 15:04:46 +01:00 committet von GitHub
Ursprung 2674d864e7
Commit d815729b6f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23

Datei anzeigen

@ -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);