Skip to content

Commit

Permalink
Deprecate PotionMeta custom name methods, add ItemMeta ones
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytv committed Dec 6, 2024
1 parent d4630f1 commit 8d1022d
Show file tree
Hide file tree
Showing 9 changed files with 238 additions and 46 deletions.
143 changes: 127 additions & 16 deletions patches/api/0006-Adventure.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4713,35 +4713,74 @@ 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 69d6de6e9618dd27f5ba73b931f8455912caf060..77f0e0a9e991f65b89909d0307fd93c3ecd9d8ac 100644
index 69d6de6e9618dd27f5ba73b931f8455912caf060..1181d62f13ad53a47bf3280f00f7ed45c826908f 100644
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
@@ -45,6 +45,24 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
*/
boolean hasDisplayName();
@@ -38,12 +38,62 @@ import org.jetbrains.annotations.Nullable;
*/
public interface ItemMeta extends Cloneable, ConfigurationSerializable, PersistentDataHolder {

+ // Paper start
+ /**
+ * Checks for existence of a custom name.
+ *
+ * @return true if this has a custom name
+ */
+ boolean hasCustomName();
+
+ /**
+ * Gets the custom name.
+ *
+ * <p>Plugins should check that {@link #hasCustomName()} returns {@code true} before calling this method.</p>
+ *
+ * @return the custom name
+ */
+ net.kyori.adventure.text.@Nullable Component customName();
+
+ /**
+ * Sets the custom name.
+ *
+ * @param customName the custom name to set
+ */
+ void customName(final net.kyori.adventure.text.@Nullable Component customName);
+
/**
* Checks for existence of a display name.
*
* @return true if this has a display name
*/
- boolean hasDisplayName();
+ @ApiStatus.Obsolete(since = "1.21.4")
+ default boolean hasDisplayName() {
+ return this.hasCustomName();
+ }
+
+ /**
+ * Gets the display name.
+ *
+ * <p>Plugins should check that {@link #hasDisplayName()} returns <code>true</code> before calling this method.</p>
+ *
+ * @return the display name
+ */
+ net.kyori.adventure.text.@Nullable Component displayName();
+ @ApiStatus.Obsolete(since = "1.21.4")
+ default net.kyori.adventure.text.@Nullable Component displayName() {
+ return this.customName();
+ }
+
+ /**
+ * Sets the display name.
+ *
+ * @param displayName the display name to set
+ */
+ void displayName(final net.kyori.adventure.text.@Nullable Component displayName);
+ @ApiStatus.Obsolete(since = "1.21.4")
+ default void displayName(final net.kyori.adventure.text.@Nullable Component displayName) {
+ this.customName(displayName);
+ }
+ // Paper end
+
/**
* Gets the display name that is set.
* <p>
@@ -52,7 +70,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -52,7 +102,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* before calling this method.
*
* @return the display name that is set
Expand All @@ -4751,7 +4790,7 @@ index 69d6de6e9618dd27f5ba73b931f8455912caf060..77f0e0a9e991f65b89909d0307fd93c3
@NotNull
String getDisplayName();

@@ -60,7 +80,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -60,7 +112,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* Sets the display name.
*
* @param name the name to set
Expand All @@ -4761,7 +4800,7 @@ index 69d6de6e9618dd27f5ba73b931f8455912caf060..77f0e0a9e991f65b89909d0307fd93c3
void setDisplayName(@Nullable String name);

/**
@@ -73,6 +95,32 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -73,6 +127,32 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
*/
boolean hasItemName();

Expand Down Expand Up @@ -4794,7 +4833,7 @@ index 69d6de6e9618dd27f5ba73b931f8455912caf060..77f0e0a9e991f65b89909d0307fd93c3
/**
* Gets the item name that is set.
* <br>
@@ -83,7 +131,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -83,7 +163,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* calling this method.
*
* @return the item name that is set
Expand All @@ -4804,7 +4843,7 @@ index 69d6de6e9618dd27f5ba73b931f8455912caf060..77f0e0a9e991f65b89909d0307fd93c3
@NotNull
String getItemName();

@@ -94,7 +144,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -94,7 +176,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
Expand All @@ -4814,7 +4853,7 @@ index 69d6de6e9618dd27f5ba73b931f8455912caf060..77f0e0a9e991f65b89909d0307fd93c3
void setItemName(@Nullable String name);

/**
@@ -135,6 +187,24 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -135,6 +219,24 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
*/
boolean hasLore();

Expand All @@ -4839,7 +4878,7 @@ index 69d6de6e9618dd27f5ba73b931f8455912caf060..77f0e0a9e991f65b89909d0307fd93c3
/**
* Gets the lore that is set.
* <p>
@@ -142,7 +212,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -142,7 +244,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* calling this method.
*
* @return a list of lore that is set
Expand All @@ -4849,7 +4888,7 @@ index 69d6de6e9618dd27f5ba73b931f8455912caf060..77f0e0a9e991f65b89909d0307fd93c3
@Nullable
List<String> getLore();

@@ -151,7 +223,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -151,7 +255,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* Removes lore when given null.
*
* @param lore the lore that will be set
Expand All @@ -4859,6 +4898,78 @@ index 69d6de6e9618dd27f5ba73b931f8455912caf060..77f0e0a9e991f65b89909d0307fd93c3
void setLore(@Nullable List<String> lore);

/**
diff --git a/src/main/java/org/bukkit/inventory/meta/PotionMeta.java b/src/main/java/org/bukkit/inventory/meta/PotionMeta.java
index b61d2e322f80fcabae5e286cba8df9701ebcf5ea..25904406ce7bf62b22621448ce982473df1d919a 100644
--- a/src/main/java/org/bukkit/inventory/meta/PotionMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/PotionMeta.java
@@ -149,9 +149,13 @@ public interface PotionMeta extends ItemMeta {
/**
* Checks for existence of a custom potion name translation suffix.
*
+ * @deprecated conflicting name, use {@link #hasCustomPotionName()}
* @return true if this has a custom potion name
*/
- boolean hasCustomName();
+ @Deprecated(forRemoval = true, since = "1.21.4")
+ default boolean hasCustomName() {
+ return this.hasCustomPotionName();
+ }

/**
* Gets the potion name translation suffix that is set.
@@ -159,17 +163,50 @@ public interface PotionMeta extends ItemMeta {
* Plugins should check that hasCustomName() returns <code>true</code>
* before calling this method.
*
+ * @deprecated conflicting name, use {@link #getCustomPotionName()}
* @return the potion name that is set
*/
+ @Deprecated(forRemoval = true, since = "1.21.4")
@Nullable
- String getCustomName();
+ default String getCustomName() {
+ return this.getCustomPotionName();
+ }

/**
* Sets the potion name translation suffix.
*
+ * @deprecated conflicting name, use {@link #setCustomPotionName(String)}
* @param name the name to set
*/
- void setCustomName(@Nullable String name);
+ @Deprecated(forRemoval = true, since = "1.21.4")
+ default void setCustomName(@Nullable String name) {
+ this.setCustomPotionName(name);
+ }
+
+ /**
+ * Checks for existence of a custom potion name translation suffix.
+ *
+ * @return true if this has a custom potion name
+ */
+ boolean hasCustomPotionName();
+
+ /**
+ * Gets the potion name translation suffix that is set.
+ * <p>
+ * Plugins should check that hasCustomName() returns {@code true}
+ * before calling this method.
+ *
+ * @return the potion name that is set
+ */
+ @Nullable
+ String getCustomPotionName();
+
+ /**
+ * Sets the potion name translation suffix.
+ *
+ * @param name the name to set
+ */
+ void setCustomPotionName(@Nullable String name);

@Override
PotionMeta clone();
diff --git a/src/main/java/org/bukkit/inventory/meta/WritableBookMeta.java b/src/main/java/org/bukkit/inventory/meta/WritableBookMeta.java
index 12595536080ffe09df2b6ecdb83d846f50100d38..9fc47c879ee6b8edf2503f20e4736c2997d2de2e 100644
--- a/src/main/java/org/bukkit/inventory/meta/WritableBookMeta.java
Expand Down
12 changes: 6 additions & 6 deletions patches/api/0053-Fix-upstream-javadocs.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1622,10 +1622,10 @@ index 35c6594fd1040a1af1029e7260e5e3a9307b107d..d58719ee75bef8bc265bfc81bc5d88a4
void addChargedProjectile(@NotNull ItemStack item);
}
diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
index 77f0e0a9e991f65b89909d0307fd93c3ecd9d8ac..66315ae78d6143ac6bde2b3a2b40b617dc4b1aab 100644
index 1181d62f13ad53a47bf3280f00f7ed45c826908f..93cce20187ae7142977233f5520e672cb554e369 100644
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
@@ -293,7 +293,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -325,7 +325,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
/**
* Gets the enchantable component. Higher values allow higher enchantments.
*
Expand All @@ -1634,7 +1634,7 @@ index 77f0e0a9e991f65b89909d0307fd93c3ecd9d8ac..66315ae78d6143ac6bde2b3a2b40b617
*/
int getEnchantable();

@@ -626,11 +626,6 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -658,11 +658,6 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste

/**
* Gets the item which this item will convert to when used.
Expand All @@ -1646,7 +1646,7 @@ index 77f0e0a9e991f65b89909d0307fd93c3ecd9d8ac..66315ae78d6143ac6bde2b3a2b40b617
*
* @return remainder
*/
@@ -767,7 +762,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -799,7 +794,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* The returned component is a snapshot of its current state and does not
* reflect a live view of what is on an item. After changing any value on
* this component, it must be set with
Expand All @@ -1655,7 +1655,7 @@ index 77f0e0a9e991f65b89909d0307fd93c3ecd9d8ac..66315ae78d6143ac6bde2b3a2b40b617
* to apply the changes.
*
* @return component
@@ -776,7 +771,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -808,7 +803,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
JukeboxPlayableComponent getJukeboxPlayable();

/**
Expand All @@ -1664,7 +1664,7 @@ index 77f0e0a9e991f65b89909d0307fd93c3ecd9d8ac..66315ae78d6143ac6bde2b3a2b40b617
*
* @param jukeboxPlayable new component
*/
@@ -803,7 +798,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -835,7 +830,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
/**
* Return an immutable copy of all {@link Attribute}s and their
* {@link AttributeModifier}s for a given {@link EquipmentSlot}.<br>
Expand Down
10 changes: 5 additions & 5 deletions patches/api/0166-Fix-Spigot-annotation-mistakes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -1748,34 +1748,34 @@ index 597a18a767b68b47e81454b7d44613c7178c1366..bc3440eb72127824b3961fbdae583bb6
public ItemStack getInput() {
return this.ingredient.getItemStack();
diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
index 66315ae78d6143ac6bde2b3a2b40b617dc4b1aab..b770541429649cefed3f7f907cc1d9653e395937 100644
index 93cce20187ae7142977233f5520e672cb554e369..e05b63c1394c5e0a34b469a8ae589480b741d548 100644
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
@@ -152,6 +152,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -184,6 +184,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
/**
* Checks for existence of a localized name.
*
+ * @deprecated Use {@link ItemMeta#displayName()} and check if it is instanceof a {@link net.kyori.adventure.text.TranslatableComponent}.
* @return true if this has a localized name
* @deprecated meta no longer exists
*/
@@ -164,6 +165,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -196,6 +197,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* Plugins should check that hasLocalizedName() returns <code>true</code>
* before calling this method.
*
+ * @deprecated Use {@link ItemMeta#displayName()} and cast it to a {@link net.kyori.adventure.text.TranslatableComponent}. No longer used by the client.
* @return the localized name that is set
* @deprecated meta no longer exists
*/
@@ -174,6 +176,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -206,6 +208,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
/**
* Sets the localized name.
*
+ * @deprecated Use {@link ItemMeta#displayName(Component)} with a {@link net.kyori.adventure.text.TranslatableComponent}. No longer used by the client.
* @param name the name to set
* @deprecated meta no longer exists
*/
@@ -767,7 +770,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -799,7 +802,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
*
* @return component
*/
Expand Down
10 changes: 5 additions & 5 deletions patches/api/0193-Support-components-in-ItemMeta.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Support components in ItemMeta


diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
index eb14949da2b96aee75e3bba63af8176c5550a380..0151a0523069b00a1cf682ad6b54142aaffcfaa6 100644
index e05b63c1394c5e0a34b469a8ae589480b741d548..261978893988ed5fba1889ba8ce5ae84897a0653 100644
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
@@ -5,6 +5,7 @@ import java.util.Collection;
Expand All @@ -16,7 +16,7 @@ index eb14949da2b96aee75e3bba63af8176c5550a380..0151a0523069b00a1cf682ad6b54142a
import org.bukkit.NamespacedKey;
import org.bukkit.Tag;
import org.bukkit.attribute.Attribute;
@@ -76,6 +77,20 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -108,6 +109,20 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@NotNull
String getDisplayName();

Expand All @@ -37,7 +37,7 @@ index eb14949da2b96aee75e3bba63af8176c5550a380..0151a0523069b00a1cf682ad6b54142a
/**
* Sets the display name.
*
@@ -85,6 +100,16 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -117,6 +132,16 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@Deprecated // Paper
void setDisplayName(@Nullable String name);

Expand All @@ -54,7 +54,7 @@ index eb14949da2b96aee75e3bba63af8176c5550a380..0151a0523069b00a1cf682ad6b54142a
/**
* Checks for existence of an item name.
* <br>
@@ -221,6 +246,19 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -253,6 +278,19 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@Nullable
List<String> getLore();

Expand All @@ -74,7 +74,7 @@ index eb14949da2b96aee75e3bba63af8176c5550a380..0151a0523069b00a1cf682ad6b54142a
/**
* Sets the lore for this item.
* Removes lore when given null.
@@ -231,6 +269,16 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -263,6 +301,16 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@Deprecated // Paper
void setLore(@Nullable List<String> lore);

Expand Down
6 changes: 3 additions & 3 deletions patches/api/0468-General-ItemMeta-fixes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ index ff6818b6d9e0207eafdd749928f33aeac3f27191..992f39da07bafe9769effaa7dc6adc01
* Checks to see if this item has a maximum amount of damage.
*
diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
index e95eac71ab43cadccf99ff594cc77a6d364c46bd..f32102441df03645c1b8c80fdfc944018e5544ca 100644
index 261978893988ed5fba1889ba8ce5ae84897a0653..16a0c8215c9cd0940fb3fbb2617569279d371a13 100644
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
@@ -351,7 +351,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -383,7 +383,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
/**
* Sets the enchantable. Higher values allow higher enchantments.
*
Expand All @@ -124,7 +124,7 @@ index e95eac71ab43cadccf99ff594cc77a6d364c46bd..f32102441df03645c1b8c80fdfc94401
*/
void setEnchantable(@Nullable Integer enchantable);

@@ -895,8 +895,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -927,8 +927,9 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste

/**
* Set all {@link Attribute}s and their {@link AttributeModifier}s.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ index 6d266c111bfa2bd51338e03ed740f6ac81ed07c7..d71531c384c57ea44d1e1fbe394214c1
return key;
}
diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
index f32102441df03645c1b8c80fdfc944018e5544ca..403c4e7138bcee1321b16fb3aa4cffb2178d4757 100644
index 16a0c8215c9cd0940fb3fbb2617569279d371a13..115c1d9fd1961499065a7fcd9aadc69095ec6778 100644
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
@@ -1028,4 +1028,98 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@@ -1060,4 +1060,98 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@SuppressWarnings("javadoc")
@NotNull
ItemMeta clone();
Expand Down
Loading

0 comments on commit 8d1022d

Please sign in to comment.