Create Meta

This commit is contained in:
Olof Larsson 2016-03-23 10:28:58 +01:00
parent c7ab4f9719
commit 777ee542b5

View File

@ -543,6 +543,13 @@ public class InventoryUtil
return (T) item.getItemMeta(); return (T) item.getItemMeta();
} }
@SuppressWarnings("unchecked")
public static <T extends ItemMeta> T createMeta(ItemStack item)
{
if (item == null) return null;
return (T) item.getItemMeta();
}
// DISPLAY NAME // DISPLAY NAME
public static String getDisplayName(ItemStack item) public static String getDisplayName(ItemStack item)
@ -556,7 +563,7 @@ public class InventoryUtil
public static void setDisplayName(ItemStack item, String displayName) public static void setDisplayName(ItemStack item, String displayName)
{ {
ItemMeta meta = getMeta(item); ItemMeta meta = createMeta(item);
if (meta == null) return; if (meta == null) return;
meta.setDisplayName(displayName); meta.setDisplayName(displayName);
@ -582,7 +589,7 @@ public class InventoryUtil
public static void setLore(ItemStack item, Collection<String> lore) public static void setLore(ItemStack item, Collection<String> lore)
{ {
ItemMeta meta = getMeta(item); ItemMeta meta = createMeta(item);
if (meta == null) return; if (meta == null) return;
meta.setLore(lore == null ? null : new MassiveList<>(lore)); meta.setLore(lore == null ? null : new MassiveList<>(lore));