From 087aa70e7cee6357f56b58ae0d2caecdb9ecf01e Mon Sep 17 00:00:00 2001 From: jmp Date: Thu, 18 Mar 2021 22:04:54 -0700 Subject: [PATCH] Deprecate ItemStack#setLore(List) and ItemStack#getLore, add Component based alternatives --- ...PI-additions-for-quantity-flags-lore.patch | 41 +++++++++++++++++-- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/Spigot-API-Patches/0113-ItemStack-API-additions-for-quantity-flags-lore.patch b/Spigot-API-Patches/0113-ItemStack-API-additions-for-quantity-flags-lore.patch index ecee6dfe6..0118df10a 100644 --- a/Spigot-API-Patches/0113-ItemStack-API-additions-for-quantity-flags-lore.patch +++ b/Spigot-API-Patches/0113-ItemStack-API-additions-for-quantity-flags-lore.patch @@ -5,7 +5,7 @@ Subject: [PATCH] ItemStack API additions for quantity/flags/lore diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index cc065602db56c51b87d273a52d9ef82439fcaa7a..db701a709d5fa2d5a6a96846e0ce2342350fb897 100644 +index cc065602db56c51b87d273a52d9ef82439fcaa7a..c6eca5a69cb8f5b161ff99ecad9475be64dcfed5 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java @@ -2,7 +2,9 @@ package org.bukkit.inventory; @@ -18,7 +18,7 @@ index cc065602db56c51b87d273a52d9ef82439fcaa7a..db701a709d5fa2d5a6a96846e0ce2342 import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Material; -@@ -635,5 +637,152 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor +@@ -635,5 +637,185 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor // Requires access to NMS return ensureServerConversions().getMaxItemUseDuration(); } @@ -89,9 +89,10 @@ index cc065602db56c51b87d273a52d9ef82439fcaa7a..db701a709d5fa2d5a6a96846e0ce2342 + /** + * If the item has lore, returns it, else it will return null + * @return The lore, or null ++ * @deprecated in favor of {@link #lore()} + */ -+ @Nullable -+ public List getLore() { ++ @Deprecated ++ public @Nullable List getLore() { + if (!hasItemMeta()) { + return null; + } @@ -103,11 +104,28 @@ index cc065602db56c51b87d273a52d9ef82439fcaa7a..db701a709d5fa2d5a6a96846e0ce2342 + } + + /** ++ * If the item has lore, returns it, else it will return null ++ * @return The lore, or null ++ */ ++ public @Nullable List lore() { ++ if (!this.hasItemMeta()) { ++ return null; ++ } ++ final ItemMeta itemMeta = getItemMeta(); ++ if (!itemMeta.hasLore()) { ++ return null; ++ } ++ return itemMeta.lore(); ++ } ++ ++ /** + * Sets the lore for this item. + * Removes lore when given null. + * + * @param lore the lore that will be set ++ * @deprecated in favour of {@link #lore(List)} + */ ++ @Deprecated + public void setLore(@Nullable List lore) { + ItemMeta itemMeta = getItemMeta(); + if (itemMeta == null) { @@ -118,6 +136,21 @@ index cc065602db56c51b87d273a52d9ef82439fcaa7a..db701a709d5fa2d5a6a96846e0ce2342 + } + + /** ++ * Sets the lore for this item. ++ * Removes lore when given null. ++ * ++ * @param lore the lore that will be set ++ */ ++ public void lore(@Nullable List lore) { ++ ItemMeta itemMeta = getItemMeta(); ++ if (itemMeta == null) { ++ throw new IllegalStateException("Cannot set lore on " + getType()); ++ } ++ itemMeta.lore(lore); ++ this.setItemMeta(itemMeta); ++ } ++ ++ /** + * Set itemflags which should be ignored when rendering a ItemStack in the Client. This Method does silently ignore double set itemFlags. + * + * @param itemFlags The hideflags which shouldn't be rendered