From 29b3f9b2bb980dcf93c2b2d6743d826bad1229a1 Mon Sep 17 00:00:00 2001
From: Aleksander Jagiello <themolkapl@gmail.com>
Date: Wed, 3 Feb 2021 18:04:27 +0100
Subject: [PATCH] Fix NPE for AIR in meta operations in ItemStack

---
 ...ack-API-additions-for-quantity-flags-lore.patch | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/Spigot-API-Patches/ItemStack-API-additions-for-quantity-flags-lore.patch b/Spigot-API-Patches/ItemStack-API-additions-for-quantity-flags-lore.patch
index 29f11c8436..3470e5404a 100644
--- a/Spigot-API-Patches/ItemStack-API-additions-for-quantity-flags-lore.patch
+++ b/Spigot-API-Patches/ItemStack-API-additions-for-quantity-flags-lore.patch
@@ -110,6 +110,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +     */
 +    public void setLore(@Nullable List<String> lore) {
 +        ItemMeta itemMeta = getItemMeta();
++        if (itemMeta == null) {
++            throw new IllegalStateException("Cannot set lore on " + getType());
++        }
 +        itemMeta.setLore(lore);
 +        setItemMeta(itemMeta);
 +    }
@@ -121,6 +124,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +     */
 +    public void addItemFlags(@NotNull ItemFlag... itemFlags) {
 +        ItemMeta itemMeta = getItemMeta();
++        if (itemMeta == null) {
++            throw new IllegalStateException("Cannot add flags on " + getType());
++        }
 +        itemMeta.addItemFlags(itemFlags);
 +        setItemMeta(itemMeta);
 +    }
@@ -132,6 +138,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +     */
 +    public void removeItemFlags(@NotNull ItemFlag... itemFlags) {
 +        ItemMeta itemMeta = getItemMeta();
++        if (itemMeta == null) {
++            throw new IllegalStateException("Cannot remove flags on " + getType());
++        }
 +        itemMeta.removeItemFlags(itemFlags);
 +        setItemMeta(itemMeta);
 +    }
@@ -144,6 +153,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +    @NotNull
 +    public Set<ItemFlag> getItemFlags() {
 +        ItemMeta itemMeta = getItemMeta();
++        if (itemMeta == null) {
++            return java.util.Collections.emptySet();
++        }
 +        return itemMeta.getItemFlags();
 +    }
 +
@@ -155,7 +167,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
 +     */
 +    public boolean hasItemFlag(@NotNull ItemFlag flag) {
 +        ItemMeta itemMeta = getItemMeta();
-+        return itemMeta.hasItemFlag(flag);
++        return itemMeta != null && itemMeta.hasItemFlag(flag);
 +    }
      // Paper end
  }