Fix NullPointerException when using air as material

This commit is contained in:
filoghost 2020-08-15 17:17:47 +02:00
parent 96934a1087
commit 862acff45c

View File

@ -275,34 +275,36 @@ public abstract class BaseConfigurableIcon implements Icon {
// Then apply data from config nodes, overwriting NBT data if there are conflicting values // Then apply data from config nodes, overwriting NBT data if there are conflicting values
ItemMeta itemMeta = itemStack.getItemMeta(); ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(renderName(viewer)); if (itemMeta != null) {
itemMeta.setLore(renderLore(viewer)); itemMeta.setDisplayName(renderName(viewer));
itemMeta.setLore(renderLore(viewer));
if (leatherColor != null && itemMeta instanceof LeatherArmorMeta) { if (leatherColor != null && itemMeta instanceof LeatherArmorMeta) {
((LeatherArmorMeta) itemMeta).setColor(leatherColor); ((LeatherArmorMeta) itemMeta).setColor(leatherColor);
}
if (skullOwner != null && itemMeta instanceof SkullMeta) {
String skullOwner = this.skullOwner.getValue(viewer);
((SkullMeta) itemMeta).setOwner(skullOwner);
}
if (itemMeta instanceof BannerMeta) {
BannerMeta bannerMeta = (BannerMeta) itemMeta;
if (bannerColor != null) {
bannerMeta.setBaseColor(bannerColor);
} }
if (bannerPatterns != null) {
((BannerMeta) itemMeta).setPatterns(bannerPatterns); if (skullOwner != null && itemMeta instanceof SkullMeta) {
String skullOwner = this.skullOwner.getValue(viewer);
((SkullMeta) itemMeta).setOwner(skullOwner);
} }
}
// Hide all text details (damage, enchantments, potions, etc,) if (itemMeta instanceof BannerMeta) {
if (itemMeta.getItemFlags().isEmpty()) { BannerMeta bannerMeta = (BannerMeta) itemMeta;
itemMeta.addItemFlags(ItemFlag.values()); if (bannerColor != null) {
} bannerMeta.setBaseColor(bannerColor);
}
if (bannerPatterns != null) {
((BannerMeta) itemMeta).setPatterns(bannerPatterns);
}
}
itemStack.setItemMeta(itemMeta); // Hide all text details (damage, enchantments, potions, etc,)
if (itemMeta.getItemFlags().isEmpty()) {
itemMeta.addItemFlags(ItemFlag.values());
}
itemStack.setItemMeta(itemMeta);
}
if (enchantments != null) { if (enchantments != null) {
enchantments.forEach(itemStack::addUnsafeEnchantment); enchantments.forEach(itemStack::addUnsafeEnchantment);