mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-17 02:34:30 +01:00
Deprecate ItemStack#setLore(List<String>) and ItemStack#getLore, add Component based alternatives
This commit is contained in:
parent
8bafc17d67
commit
a724816abb
1 changed files with 35 additions and 2 deletions
|
@ -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<String> getLore() {
|
||||
+ @Deprecated
|
||||
+ public @Nullable List<String> 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<net.kyori.adventure.text.Component> 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<String> 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<net.kyori.adventure.text.Component> 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
|
||||
|
|
Loading…
Add table
Reference in a new issue