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>
Dieser Commit ist enthalten in:
Shane Freeder 2024-04-28 18:08:59 +01:00 committet von GitHub
Ursprung 0f4d328fc1
Commit 52ff3b7382
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
12 geänderte Dateien mit 112 neuen und 40 gelöschten Zeilen

Datei anzeigen

@ -4596,7 +4596,7 @@ index 9bab73c3c2ca759b8e1c7d07d98cc593c961666a..f0c6943da3f783101ca647b75b3230fa
throw new UnsupportedOperationException("Not supported yet."); 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 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 --- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
+++ b/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 @@ -34,6 +34,24 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@ -4644,7 +4644,60 @@ index 255f79d5bca15620cb17d7b54ffebb6ff00bff6b..d7c178b3584db5866a5a21c6ddaab876
void setDisplayName(@Nullable String name); 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(); boolean hasLore();
@ -4669,7 +4722,7 @@ index 255f79d5bca15620cb17d7b54ffebb6ff00bff6b..d7c178b3584db5866a5a21c6ddaab876
/** /**
* Gets the lore that is set. * Gets the lore that is set.
* <p> * <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. * calling this method.
* *
* @return a list of lore that is set * @return a list of lore that is set
@ -4679,7 +4732,7 @@ index 255f79d5bca15620cb17d7b54ffebb6ff00bff6b..d7c178b3584db5866a5a21c6ddaab876
@Nullable @Nullable
List<String> getLore(); 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. * Removes lore when given null.
* *
* @param lore the lore that will be set * @param lore the lore that will be set

Datei anzeigen

@ -1438,10 +1438,10 @@ index 07c3dff4d6190ef388d9c1e1c36f67f00a3e8e66..597a18a767b68b47e81454b7d44613c7
* @param input The input choice. * @param input The input choice.
* @return The changed recipe, so you can chain calls. * @return The changed recipe, so you can chain calls.
diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
index d7c178b3584db5866a5a21c6ddaab876b94058b9..dff32cedf47e95fe14a865898d76b62748dee5f3 100644 index 18c2864c99d4dfae16cdb35143486aeebb9a6fd6..d66857825528ee772219440dffa28ad8e820493b 100644
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java --- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
@@ -483,7 +483,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste @@ -513,7 +513,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
/** /**
* Return an immutable copy of all {@link Attribute}s and their * Return an immutable copy of all {@link Attribute}s and their
* {@link AttributeModifier}s for a given {@link EquipmentSlot}.<br> * {@link AttributeModifier}s for a given {@link EquipmentSlot}.<br>

Datei anzeigen

@ -1587,10 +1587,10 @@ index 597a18a767b68b47e81454b7d44613c7178c1366..bc3440eb72127824b3961fbdae583bb6
public ItemStack getInput() { public ItemStack getInput() {
return this.ingredient.getItemStack(); 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 diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
index dff32cedf47e95fe14a865898d76b62748dee5f3..05a57b42e874c6e50149aa253861abaf5e17cef0 100644 index d66857825528ee772219440dffa28ad8e820493b..3ddd52b135f339ff006b5d53f46487bfbe1ff7fd 100644
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java --- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
+++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +++ b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
@@ -111,6 +111,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste @@ -141,6 +141,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
/** /**
* Checks for existence of a localized name. * Checks for existence of a localized name.
* *
@ -1598,7 +1598,7 @@ index dff32cedf47e95fe14a865898d76b62748dee5f3..05a57b42e874c6e50149aa253861abaf
* @return true if this has a localized name * @return true if this has a localized name
* @deprecated meta no longer exists * @deprecated meta no longer exists
*/ */
@@ -123,6 +124,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste @@ -153,6 +154,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
* Plugins should check that hasLocalizedName() returns <code>true</code> * Plugins should check that hasLocalizedName() returns <code>true</code>
* before calling this method. * before calling this method.
* *
@ -1606,7 +1606,7 @@ index dff32cedf47e95fe14a865898d76b62748dee5f3..05a57b42e874c6e50149aa253861abaf
* @return the localized name that is set * @return the localized name that is set
* @deprecated meta no longer exists * @deprecated meta no longer exists
*/ */
@@ -133,6 +135,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste @@ -163,6 +165,7 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
/** /**
* Sets the localized name. * Sets the localized name.
* *

Datei anzeigen

@ -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 diff --git a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
index 05a57b42e874c6e50149aa253861abaf5e17cef0..ab69711ebd81fb512c7abebc5b439e89a4754bd2 100644 index 3ddd52b135f339ff006b5d53f46487bfbe1ff7fd..ed12e27a0ed75caa8aa46c3e965ed566a97865cf 100644
--- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java --- a/src/main/java/org/bukkit/inventory/meta/ItemMeta.java
+++ b/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; @@ -5,6 +5,7 @@ import java.util.Collection;
@ -54,7 +54,7 @@ index 05a57b42e874c6e50149aa253861abaf5e17cef0..ab69711ebd81fb512c7abebc5b439e89
/** /**
* Checks for existence of an item name. * Checks for existence of an item name.
* <br> * <br>
@@ -180,6 +205,19 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste @@ -210,6 +235,19 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@Nullable @Nullable
List<String> getLore(); List<String> getLore();
@ -74,7 +74,7 @@ index 05a57b42e874c6e50149aa253861abaf5e17cef0..ab69711ebd81fb512c7abebc5b439e89
/** /**
* Sets the lore for this item. * Sets the lore for this item.
* Removes lore when given null. * Removes lore when given null.
@@ -190,6 +228,16 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste @@ -220,6 +258,16 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste
@Deprecated // Paper @Deprecated // Paper
void setLore(@Nullable List<String> lore); void setLore(@Nullable List<String> lore);

Datei anzeigen

@ -5141,7 +5141,7 @@ index 9c57b883783145ad4483481a2c2e7f0f188cd174..b653c2c80e8e8524ea6d7625c6a86f82
+ // Paper end + // Paper end
} }
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index 7a5110efc5af1be6644b7afecd6ac025c20e6794..3cb5685a97f67d759537fc92bb4cb376bb2905a7 100644 index 7a5110efc5af1be6644b7afecd6ac025c20e6794..b79f29ccd512ec7d2a8f6a885c1a96dfd58e7dc5 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -843,6 +843,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -843,6 +843,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@ -5163,7 +5163,26 @@ index 7a5110efc5af1be6644b7afecd6ac025c20e6794..3cb5685a97f67d759537fc92bb4cb376
@Override @Override
public String getDisplayName() { public String getDisplayName() {
return CraftChatMessage.fromComponent(this.displayName); return CraftChatMessage.fromComponent(this.displayName);
@@ -892,6 +904,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -873,6 +885,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
return this.itemName != null;
}
+ // Paper start - Adventure
+ @Override
+ public net.kyori.adventure.text.Component itemName() {
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(this.itemName);
+ }
+
+ @Override
+ public void itemName(final net.kyori.adventure.text.Component name) {
+ this.itemName = io.papermc.paper.adventure.PaperAdventure.asVanilla(name);
+ }
+ // Paper end - Adventure
+
@Override
public String getLocalizedName() {
return this.getDisplayName();
@@ -892,6 +916,18 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
return this.lore != null && !this.lore.isEmpty(); return this.lore != null && !this.lore.isEmpty();
} }

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Support components in ItemMeta
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index 3cb5685a97f67d759537fc92bb4cb376bb2905a7..e967d6b32d9538d8456d73a67a73e3d3ea16b831 100644 index 780b7e971a9d4fda1a9c78790c7969a0799f51ab..e663c996146986bc02efb05b4fb452913e4015d7 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -860,11 +860,23 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -860,11 +860,23 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@ -32,7 +32,7 @@ index 3cb5685a97f67d759537fc92bb4cb376bb2905a7..e967d6b32d9538d8456d73a67a73e3d3
@Override @Override
public boolean hasDisplayName() { public boolean hasDisplayName() {
return this.displayName != null; return this.displayName != null;
@@ -1026,6 +1038,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -1038,6 +1050,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
return this.lore == null ? null : new ArrayList<String>(Lists.transform(this.lore, CraftChatMessage::fromComponent)); return this.lore == null ? null : new ArrayList<String>(Lists.transform(this.lore, CraftChatMessage::fromComponent));
} }
@ -47,7 +47,7 @@ index 3cb5685a97f67d759537fc92bb4cb376bb2905a7..e967d6b32d9538d8456d73a67a73e3d3
@Override @Override
public void setLore(List<String> lore) { public void setLore(List<String> lore) {
if (lore == null || lore.isEmpty()) { if (lore == null || lore.isEmpty()) {
@@ -1040,6 +1060,21 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -1052,6 +1072,21 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
} }
} }
@ -69,7 +69,7 @@ index 3cb5685a97f67d759537fc92bb4cb376bb2905a7..e967d6b32d9538d8456d73a67a73e3d3
@Override @Override
public boolean hasCustomModelData() { public boolean hasCustomModelData() {
return this.customModelData != null; return this.customModelData != null;
@@ -1663,6 +1698,11 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -1675,6 +1710,11 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
} }
for (Object object : addFrom) { for (Object object : addFrom) {

Datei anzeigen

@ -150,7 +150,7 @@ index b6521462d193bff83ace1dc694c6d957a7173969..d302767e8f01fdfcba9c22e2e35677af
static Map<Enchantment, Integer> getEnchantments(net.minecraft.world.item.ItemStack item) { static Map<Enchantment, Integer> getEnchantments(net.minecraft.world.item.ItemStack item) {
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index e967d6b32d9538d8456d73a67a73e3d3ea16b831..e88364dfe067c605856390d2cce07ba320632df9 100644 index e663c996146986bc02efb05b4fb452913e4015d7..954aa31f5890deacbf2004aed8722360a87da7f1 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -6,6 +6,7 @@ import com.google.common.collect.ImmutableList; @@ -6,6 +6,7 @@ import com.google.common.collect.ImmutableList;
@ -222,7 +222,7 @@ index e967d6b32d9538d8456d73a67a73e3d3ea16b831..e88364dfe067c605856390d2cce07ba3
for (Map.Entry<?, ?> entry : ench.entrySet()) { for (Map.Entry<?, ?> entry : ench.entrySet()) {
// Doctor older enchants // Doctor older enchants
String enchantKey = entry.getKey().toString(); String enchantKey = entry.getKey().toString();
@@ -951,14 +954,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -963,14 +966,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Override @Override
public Map<Enchantment, Integer> getEnchants() { public Map<Enchantment, Integer> getEnchants() {
@ -239,7 +239,7 @@ index e967d6b32d9538d8456d73a67a73e3d3ea16b831..e88364dfe067c605856390d2cce07ba3
} }
if (ignoreRestrictions || level >= ench.getStartLevel() && level <= ench.getMaxLevel()) { if (ignoreRestrictions || level >= ench.getStartLevel() && level <= ench.getMaxLevel()) {
@@ -1494,7 +1497,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -1506,7 +1509,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
clone.customModelData = this.customModelData; clone.customModelData = this.customModelData;
clone.blockData = this.blockData; clone.blockData = this.blockData;
if (this.enchantments != null) { if (this.enchantments != null) {
@ -248,7 +248,7 @@ index e967d6b32d9538d8456d73a67a73e3d3ea16b831..e88364dfe067c605856390d2cce07ba3
} }
if (this.hasAttributeModifiers()) { if (this.hasAttributeModifiers()) {
clone.attributeModifiers = LinkedHashMultimap.create(this.attributeModifiers); clone.attributeModifiers = LinkedHashMultimap.create(this.attributeModifiers);
@@ -1814,4 +1817,22 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -1826,4 +1829,22 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
return (result != null) ? result : Optional.empty(); return (result != null) ? result : Optional.empty();
} }

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Fix CraftMetaItem#getAttributeModifier duplication check
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index 069666c797c39b5119e41a3c18727f89fcc3b8c5..fac6f3aa00b209e6090f4cb0207e53a994e51cac 100644 index 796f7e5ce2661339081214369497318fb32d2743..f24f911bed23016e9e8d17c777481b7af45a5400 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -1255,7 +1255,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -1267,7 +1267,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
Preconditions.checkNotNull(modifier, "AttributeModifier cannot be null"); Preconditions.checkNotNull(modifier, "AttributeModifier cannot be null");
this.checkAttributeList(); this.checkAttributeList();
for (Map.Entry<Attribute, AttributeModifier> entry : this.attributeModifiers.entries()) { for (Map.Entry<Attribute, AttributeModifier> entry : this.attributeModifiers.entries()) {

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Deep clone nbt tags in PDC
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index 7626ccaec65acbda22738296b4dd4423ee535aa8..ca41754a8224ad0fe959c982a4b6adfd8b346b05 100644 index feea880d29ca7019bcdfa5232bea2b8ca8c3f644..2c4e7cfe71a9a960e7ac84b19ce32b478b9da3c3 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -284,7 +284,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -284,7 +284,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@ -17,7 +17,7 @@ index 7626ccaec65acbda22738296b4dd4423ee535aa8..ca41754a8224ad0fe959c982a4b6adfd
this.customTag = meta.customTag; this.customTag = meta.customTag;
@@ -1511,7 +1511,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -1523,7 +1523,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
if (this.customTag != null) { if (this.customTag != null) {
clone.customTag = this.customTag.copy(); clone.customTag = this.customTag.copy();
} }

Datei anzeigen

@ -128,7 +128,7 @@ index ba58f0f2f4f9cb99fb6cecfe772ae5781f976b63..04a0f63411ed95bcf5bac1689d29bbe5
} }
// Paper start // Paper start
@@ -1455,6 +1497,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -1467,6 +1509,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
&& (this.hasFood() ? that.hasFood() && this.food.equals(that.food) : !that.hasFood()) && (this.hasFood() ? that.hasFood() && this.food.equals(that.food) : !that.hasFood())
&& (this.hasDamage() ? that.hasDamage() && this.damage == that.damage : !that.hasDamage()) && (this.hasDamage() ? that.hasDamage() && this.damage == that.damage : !that.hasDamage())
&& (this.hasMaxDamage() ? that.hasMaxDamage() && this.maxDamage.equals(that.maxDamage) : !that.hasMaxDamage()) && (this.hasMaxDamage() ? that.hasMaxDamage() && this.maxDamage.equals(that.maxDamage) : !that.hasMaxDamage())
@ -137,7 +137,7 @@ index ba58f0f2f4f9cb99fb6cecfe772ae5781f976b63..04a0f63411ed95bcf5bac1689d29bbe5
&& (this.version == that.version); && (this.version == that.version);
} }
@@ -1497,6 +1541,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -1509,6 +1553,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
hash = 61 * hash + (this.hasDamage() ? this.damage : 0); hash = 61 * hash + (this.hasDamage() ? this.damage : 0);
hash = 61 * hash + (this.hasMaxDamage() ? 1231 : 1237); hash = 61 * hash + (this.hasMaxDamage() ? 1231 : 1237);
hash = 61 * hash + (this.hasAttributeModifiers() ? this.attributeModifiers.hashCode() : 0); hash = 61 * hash + (this.hasAttributeModifiers() ? this.attributeModifiers.hashCode() : 0);
@ -146,7 +146,7 @@ index ba58f0f2f4f9cb99fb6cecfe772ae5781f976b63..04a0f63411ed95bcf5bac1689d29bbe5
hash = 61 * hash + this.version; hash = 61 * hash + this.version;
return hash; return hash;
} }
@@ -1534,6 +1580,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -1546,6 +1592,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
clone.damage = this.damage; clone.damage = this.damage;
clone.maxDamage = this.maxDamage; clone.maxDamage = this.maxDamage;
clone.version = this.version; clone.version = this.version;
@ -161,7 +161,7 @@ index ba58f0f2f4f9cb99fb6cecfe772ae5781f976b63..04a0f63411ed95bcf5bac1689d29bbe5
return clone; return clone;
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
throw new Error(e); throw new Error(e);
@@ -1643,6 +1697,16 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -1655,6 +1709,16 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
} }
} }
@ -178,7 +178,7 @@ index ba58f0f2f4f9cb99fb6cecfe772ae5781f976b63..04a0f63411ed95bcf5bac1689d29bbe5
if (!this.unhandledTags.isEmpty()) { if (!this.unhandledTags.isEmpty()) {
Tag unhandled = DataComponentPatch.CODEC.encodeStart(MinecraftServer.getDefaultRegistryAccess().createSerializationContext(NbtOps.INSTANCE), this.unhandledTags.build()).getOrThrow(IllegalStateException::new); Tag unhandled = DataComponentPatch.CODEC.encodeStart(MinecraftServer.getDefaultRegistryAccess().createSerializationContext(NbtOps.INSTANCE), this.unhandledTags.build()).getOrThrow(IllegalStateException::new);
try { try {
@@ -1653,6 +1717,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -1665,6 +1729,14 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
Logger.getLogger(CraftMetaItem.class.getName()).log(Level.SEVERE, null, ex); Logger.getLogger(CraftMetaItem.class.getName()).log(Level.SEVERE, null, ex);
} }
} }
@ -193,7 +193,7 @@ index ba58f0f2f4f9cb99fb6cecfe772ae5781f976b63..04a0f63411ed95bcf5bac1689d29bbe5
if (!this.persistentDataContainer.isEmpty()) { // Store custom tags, wrapped in their compound if (!this.persistentDataContainer.isEmpty()) { // Store custom tags, wrapped in their compound
builder.put(CraftMetaItem.BUKKIT_CUSTOM_TAG.BUKKIT, this.persistentDataContainer.serialize()); builder.put(CraftMetaItem.BUKKIT_CUSTOM_TAG.BUKKIT, this.persistentDataContainer.serialize());
@@ -1794,6 +1866,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -1806,6 +1878,8 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
CraftMetaItem.MAX_DAMAGE.TYPE, CraftMetaItem.MAX_DAMAGE.TYPE,
CraftMetaItem.CUSTOM_DATA.TYPE, CraftMetaItem.CUSTOM_DATA.TYPE,
CraftMetaItem.ATTRIBUTES.TYPE, CraftMetaItem.ATTRIBUTES.TYPE,

Datei anzeigen

@ -404,7 +404,7 @@ index b444bd26d6c3def3494d3cc0520e462408272be3..8e0dd4b7a7a25a8beb27b507047bc48d
getOrEmpty(tag, CraftMetaFirework.FIREWORKS).ifPresent((fireworks) -> { getOrEmpty(tag, CraftMetaFirework.FIREWORKS).ifPresent((fireworks) -> {
this.power = fireworks.flightDuration(); this.power = fireworks.flightDuration();
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index 9cd528a70ef3e6053a7103a6f9df5e93bb8550a4..8973a08f39279415e28a4fadf0015f1ab9581350 100644 index f41ce4d2184aeb3c6b852d28073bb7ae265d03c3..7c5f9c711c2364ec3a47aed1203df370ed85a3c8 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -308,7 +308,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -308,7 +308,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@ -436,7 +436,7 @@ index 9cd528a70ef3e6053a7103a6f9df5e93bb8550a4..8973a08f39279415e28a4fadf0015f1a
key.getValue().ifPresentOrElse((value) -> { key.getValue().ifPresentOrElse((value) -> {
this.unhandledTags.set((DataComponentType) key.getKey(), value); this.unhandledTags.set((DataComponentType) key.getKey(), value);
}, () -> { }, () -> {
@@ -1843,63 +1850,73 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -1855,63 +1862,73 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
this.version = version; this.version = version;
} }

Datei anzeigen

@ -159,7 +159,7 @@ index 8e0dd4b7a7a25a8beb27b507047bc48d8227627c..cf5d27ccc2225bac3aa57912f444f95d
@Override @Override
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
index 651871b4fc512747bdfa6166c2d21b4f174f5cee..ba7d2b48552b36c6519724893e4054277e7a0cdc 100644 index 7765f774bfdbead492ad6427873b8bc94ef64a4b..c2517ad00b6efba47e792a46e591038d79cb3a82 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
@@ -165,9 +165,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -165,9 +165,10 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@ -174,7 +174,7 @@ index 651871b4fc512747bdfa6166c2d21b4f174f5cee..ba7d2b48552b36c6519724893e405427
<T> Applicator put(ItemMetaKeyType<T> key, T value) { <T> Applicator put(ItemMetaKeyType<T> key, T value) {
this.builder.set(key.TYPE, value); this.builder.set(key.TYPE, value);
@@ -991,6 +992,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -1003,6 +1004,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Override @Override
public void lore(final List<? extends net.kyori.adventure.text.Component> lore) { public void lore(final List<? extends net.kyori.adventure.text.Component> lore) {
@ -182,7 +182,7 @@ index 651871b4fc512747bdfa6166c2d21b4f174f5cee..ba7d2b48552b36c6519724893e405427
this.lore = lore != null ? io.papermc.paper.adventure.PaperAdventure.asVanilla(lore) : null; this.lore = lore != null ? io.papermc.paper.adventure.PaperAdventure.asVanilla(lore) : null;
} }
// Paper end // Paper end
@@ -1115,6 +1117,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -1127,6 +1129,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
// Paper end // Paper end
@Override @Override
public void setLore(List<String> lore) { public void setLore(List<String> lore) {
@ -190,7 +190,7 @@ index 651871b4fc512747bdfa6166c2d21b4f174f5cee..ba7d2b48552b36c6519724893e405427
if (lore == null || lore.isEmpty()) { if (lore == null || lore.isEmpty()) {
this.lore = null; this.lore = null;
} else { } else {
@@ -1130,6 +1133,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -1142,6 +1145,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
// Paper start // Paper start
@Override @Override
public void setLoreComponents(List<net.md_5.bungee.api.chat.BaseComponent[]> lore) { public void setLoreComponents(List<net.md_5.bungee.api.chat.BaseComponent[]> lore) {
@ -198,7 +198,7 @@ index 651871b4fc512747bdfa6166c2d21b4f174f5cee..ba7d2b48552b36c6519724893e405427
if (lore == null) { if (lore == null) {
this.lore = null; this.lore = null;
} else { } else {
@@ -1397,7 +1401,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta { @@ -1409,7 +1413,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Override @Override
public String getAsString() { public String getAsString() {