Add itemName components (Resolves #10467) (#10471)

* Add itemName components (Resolves ##10467)

* improve javadocs and formatting

* rebased

---------

Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
This commit is contained in:
Shane Freeder 2024-04-28 18:08:59 +01:00 committed by GitHub
parent 0f4d328fc1
commit 52ff3b7382
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 112 additions and 40 deletions

View file

@ -4596,7 +4596,7 @@ index 9bab73c3c2ca759b8e1c7d07d98cc593c961666a..f0c6943da3f783101ca647b75b3230fa
throw new UnsupportedOperationException("Not supported yet.");
}
diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
index 255f79d5bca15620cb17d7b54ffebb6ff00bff6b..d7c178b3584db5866a5a21c6ddaab876b94058b9 100644
index 255f79d5bca15620cb17d7b54ffebb6ff00bff6b..18c2864c99d4dfae16cdb35143486aeebb9a6fd6 100644
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
@@ -34,6 +34,24 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@ -4644,7 +4644,60 @@ index 255f79d5bca15620cb17d7b54ffebb6ff00bff6b..d7c178b3584db5866a5a21c6ddaab876
void setDisplayName(@Nullable String name);
/**
@@ -124,6 +146,24 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -62,6 +84,32 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
*/
boolean hasItemName();
+ // Paper start
+ /**
+ * Gets the item name component that is set.
+ * <br>
+ * Item name differs from display name in that it is cannot be edited by an
+ * anvil, is not styled with italics, and does not show labels.
+ * <p>
+ * Plugins should check that {@link #hasItemName()} returns <code>true</code> before
+ * calling this method.
+ *
+ * @return the item name that is set
+ * @see #hasItemName()
+ */
+ @org.jetbrains.annotations.NotNull
+ Component itemName();
+
+ /**
+ * Sets the item name.
+ * <br>
+ * Item name differs from display name in that it is cannot be edited by an
+ * anvil, is not styled with italics, and does not show labels.
+ *
+ * @param name the name to set, null to remove it
+ */
+ void itemName(@Nullable final Component name);
+ // Paper end
/**
* Gets the item name that is set.
* <br>
@@ -72,7 +120,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* calling this method.
*
* @return the item name that is set
+ * @deprecated in favour of {@link #itemName()}
*/
+ @Deprecated // Paper
@NotNull
String getItemName();
@@ -83,7 +133,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* anvil, is not styled with italics, and does not show labels.
*
* @param name the name to set
+ * @deprecated in favour of {@link #itemName(Component)}
*/
+ @Deprecated // Paper
void setItemName(@Nullable String name);
/**
@@ -124,6 +176,24 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
*/
boolean hasLore();
@ -4669,7 +4722,7 @@ index 255f79d5bca15620cb17d7b54ffebb6ff00bff6b..d7c178b3584db5866a5a21c6ddaab876
/**
* Gets the lore that is set.
* <p>
@@ -131,7 +171,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -131,7 +201,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* calling this method.
*
* @return a list of lore that is set
@ -4679,7 +4732,7 @@ index 255f79d5bca15620cb17d7b54ffebb6ff00bff6b..d7c178b3584db5866a5a21c6ddaab876
@Nullable
List<String> getLore();
@@ -140,7 +182,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -140,7 +212,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* Removes lore when given null.
*
* @param lore the lore that will be set