From a724816abb0e0c62078ee67f80c164d40b4e8240 Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> 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 | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) 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 3470e5404a..e9e1e54574 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 @@ -89,9 +89,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + /** + * 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** ++ * 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 + } + + /** ++ * 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