From 2716a6bbcb274721063c450b7f8a9124073f7410 Mon Sep 17 00:00:00 2001 From: masmc05 Date: Sat, 5 Oct 2024 04:24:42 +0300 Subject: [PATCH 1/4] Add ItemStack#effectiveName --- .../0495-Add-ItemStack-effectiveName.patch | 28 +++++++++++++ .../1065-Add-ItemStack-effectiveName.patch | 42 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 patches/api/0495-Add-ItemStack-effectiveName.patch create mode 100644 patches/server/1065-Add-ItemStack-effectiveName.patch diff --git a/patches/api/0495-Add-ItemStack-effectiveName.patch b/patches/api/0495-Add-ItemStack-effectiveName.patch new file mode 100644 index 000000000000..92de9bc4645c --- /dev/null +++ b/patches/api/0495-Add-ItemStack-effectiveName.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: masmc05 +Date: Sat, 5 Oct 2024 04:23:14 +0300 +Subject: [PATCH] Add ItemStack#effectiveName + + +diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java +index b59222b8c262545d100a9fd28b3bf1d2a4cf4eb0..7cf153d31c85fa852e90011392d1e09034bbee34 100644 +--- a/src/main/java/org/bukkit/inventory/ItemStack.java ++++ b/src/main/java/org/bukkit/inventory/ItemStack.java +@@ -710,6 +710,17 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat + return Bukkit.getServer().getItemFactory().displayName(this); + } + ++ /** ++ * Gets the effective name of this item stack shown to player in inventory. ++ * It takes into account the display name (with italics) from the item meta, ++ * the potion effect, translatable name, rarity etc. ++ * ++ * @return the effective name of this item stack ++ */ ++ public net.kyori.adventure.text.@NotNull Component effectiveName() { ++ return this.craftDelegate.effectiveName(); ++ } ++ + /** + * Minecraft updates are converting simple item stacks into more complex NBT oriented Item Stacks. + * diff --git a/patches/server/1065-Add-ItemStack-effectiveName.patch b/patches/server/1065-Add-ItemStack-effectiveName.patch new file mode 100644 index 000000000000..ff410523ef73 --- /dev/null +++ b/patches/server/1065-Add-ItemStack-effectiveName.patch @@ -0,0 +1,42 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: masmc05 +Date: Sat, 5 Oct 2024 04:23:13 +0300 +Subject: [PATCH] Add ItemStack#effectiveName + + +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +index f84e07fa0876bb6da0f99f4de6cb811f897adca2..e2191bc42951760b67e475e50be38c6abb3a77b7 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +@@ -22,6 +22,7 @@ import org.bukkit.inventory.ItemStack; + import org.bukkit.inventory.meta.ItemMeta; + import org.bukkit.material.MaterialData; + import org.jetbrains.annotations.ApiStatus; ++import org.jetbrains.annotations.NotNull; + + @DelegateDeserialization(ItemStack.class) + public final class CraftItemStack extends ItemStack { +@@ -438,6 +439,23 @@ public final class CraftItemStack extends ItemStack { + return true; + } + ++ // Paper start - add ItemStack#effectiveName ++ @Override ++ public @NotNull net.kyori.adventure.text.Component effectiveName() { ++ // 1.21.2: return this.handle == null ? net.kyori.adventure.text.Component.empty() : io.papermc.paper.adventure.PaperAdventure.asAdventure(this.handle.getStyledHoverName()); ++ if (this.handle == null) { ++ return net.kyori.adventure.text.Component.empty(); ++ } ++ net.kyori.adventure.text.Component hover = io.papermc.paper.adventure.PaperAdventure.asAdventure(this.handle.getHoverName()); ++ net.kyori.adventure.text.format.Style.Builder style = hover.style().toBuilder(); ++ style.color(io.papermc.paper.adventure.PaperAdventure.asAdventure(this.handle.getRarity().color())); ++ if (this.handle.has(DataComponents.CUSTOM_NAME)) { ++ style.decoration(net.kyori.adventure.text.format.TextDecoration.ITALIC, true); ++ } ++ return hover.style(style); ++ } ++ // Paper end - add ItemStack#effectiveName ++ + @Override + public boolean isSimilar(ItemStack stack) { + if (stack == null) { From da6657ece416f4d42af0254e9e2665b61bc95657 Mon Sep 17 00:00:00 2001 From: masmc05 Date: Sat, 5 Oct 2024 04:30:33 +0300 Subject: [PATCH 2/4] Kill the NotNull annotation --- .../server/1065-Add-ItemStack-effectiveName.patch | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/patches/server/1065-Add-ItemStack-effectiveName.patch b/patches/server/1065-Add-ItemStack-effectiveName.patch index ff410523ef73..d003da1f017a 100644 --- a/patches/server/1065-Add-ItemStack-effectiveName.patch +++ b/patches/server/1065-Add-ItemStack-effectiveName.patch @@ -5,24 +5,16 @@ Subject: [PATCH] Add ItemStack#effectiveName diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -index f84e07fa0876bb6da0f99f4de6cb811f897adca2..e2191bc42951760b67e475e50be38c6abb3a77b7 100644 +index f84e07fa0876bb6da0f99f4de6cb811f897adca2..c6a24aca51a612a02f677f2870b5afcfb7b2d47e 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -@@ -22,6 +22,7 @@ import org.bukkit.inventory.ItemStack; - import org.bukkit.inventory.meta.ItemMeta; - import org.bukkit.material.MaterialData; - import org.jetbrains.annotations.ApiStatus; -+import org.jetbrains.annotations.NotNull; - - @DelegateDeserialization(ItemStack.class) - public final class CraftItemStack extends ItemStack { -@@ -438,6 +439,23 @@ public final class CraftItemStack extends ItemStack { +@@ -438,6 +438,23 @@ public final class CraftItemStack extends ItemStack { return true; } + // Paper start - add ItemStack#effectiveName + @Override -+ public @NotNull net.kyori.adventure.text.Component effectiveName() { ++ public net.kyori.adventure.text.Component effectiveName() { + // 1.21.2: return this.handle == null ? net.kyori.adventure.text.Component.empty() : io.papermc.paper.adventure.PaperAdventure.asAdventure(this.handle.getStyledHoverName()); + if (this.handle == null) { + return net.kyori.adventure.text.Component.empty(); From 796ee77f6d32e4b43ebb2fc8d38ee864e4602603 Mon Sep 17 00:00:00 2001 From: masmc05 Date: Sun, 24 Nov 2024 15:20:24 +0200 Subject: [PATCH 3/4] Rebase to 1.21.3 --- ...=> 0501-Add-ItemStack-effectiveName.patch} | 2 +- .../1065-Add-ItemStack-effectiveName.patch | 34 ------------------- .../1073-Add-ItemStack-effectiveName.patch | 24 +++++++++++++ 3 files changed, 25 insertions(+), 35 deletions(-) rename patches/api/{0495-Add-ItemStack-effectiveName.patch => 0501-Add-ItemStack-effectiveName.patch} (92%) delete mode 100644 patches/server/1065-Add-ItemStack-effectiveName.patch create mode 100644 patches/server/1073-Add-ItemStack-effectiveName.patch diff --git a/patches/api/0495-Add-ItemStack-effectiveName.patch b/patches/api/0501-Add-ItemStack-effectiveName.patch similarity index 92% rename from patches/api/0495-Add-ItemStack-effectiveName.patch rename to patches/api/0501-Add-ItemStack-effectiveName.patch index 92de9bc4645c..0261e59549c9 100644 --- a/patches/api/0495-Add-ItemStack-effectiveName.patch +++ b/patches/api/0501-Add-ItemStack-effectiveName.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add ItemStack#effectiveName diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index b59222b8c262545d100a9fd28b3bf1d2a4cf4eb0..7cf153d31c85fa852e90011392d1e09034bbee34 100644 +index 6e4ca7d95953a25c0aaafd35e54ef9254a1b5f0b..cb787210c1333b32566c394dcc8188be0894d147 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java @@ -710,6 +710,17 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat diff --git a/patches/server/1065-Add-ItemStack-effectiveName.patch b/patches/server/1065-Add-ItemStack-effectiveName.patch deleted file mode 100644 index d003da1f017a..000000000000 --- a/patches/server/1065-Add-ItemStack-effectiveName.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: masmc05 -Date: Sat, 5 Oct 2024 04:23:13 +0300 -Subject: [PATCH] Add ItemStack#effectiveName - - -diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -index f84e07fa0876bb6da0f99f4de6cb811f897adca2..c6a24aca51a612a02f677f2870b5afcfb7b2d47e 100644 ---- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -@@ -438,6 +438,23 @@ public final class CraftItemStack extends ItemStack { - return true; - } - -+ // Paper start - add ItemStack#effectiveName -+ @Override -+ public net.kyori.adventure.text.Component effectiveName() { -+ // 1.21.2: return this.handle == null ? net.kyori.adventure.text.Component.empty() : io.papermc.paper.adventure.PaperAdventure.asAdventure(this.handle.getStyledHoverName()); -+ if (this.handle == null) { -+ return net.kyori.adventure.text.Component.empty(); -+ } -+ net.kyori.adventure.text.Component hover = io.papermc.paper.adventure.PaperAdventure.asAdventure(this.handle.getHoverName()); -+ net.kyori.adventure.text.format.Style.Builder style = hover.style().toBuilder(); -+ style.color(io.papermc.paper.adventure.PaperAdventure.asAdventure(this.handle.getRarity().color())); -+ if (this.handle.has(DataComponents.CUSTOM_NAME)) { -+ style.decoration(net.kyori.adventure.text.format.TextDecoration.ITALIC, true); -+ } -+ return hover.style(style); -+ } -+ // Paper end - add ItemStack#effectiveName -+ - @Override - public boolean isSimilar(ItemStack stack) { - if (stack == null) { diff --git a/patches/server/1073-Add-ItemStack-effectiveName.patch b/patches/server/1073-Add-ItemStack-effectiveName.patch new file mode 100644 index 000000000000..29fd3277bc27 --- /dev/null +++ b/patches/server/1073-Add-ItemStack-effectiveName.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: masmc05 +Date: Sat, 5 Oct 2024 04:23:13 +0300 +Subject: [PATCH] Add ItemStack#effectiveName + + +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +index ccad5a7018f6eaacb011818e9da990c75e0d06df..427e0fb8e932cf401a5e0ae7c310fe338554dd27 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +@@ -469,6 +469,13 @@ public final class CraftItemStack extends ItemStack { + return true; + } + ++ // Paper start - add ItemStack#effectiveName ++ @Override ++ public net.kyori.adventure.text.Component effectiveName() { ++ return this.handle == null ? net.kyori.adventure.text.Component.empty() : io.papermc.paper.adventure.PaperAdventure.asAdventure(this.handle.getStyledHoverName()); ++ } ++ // Paper end - add ItemStack#effectiveName ++ + @Override + public boolean isSimilar(ItemStack stack) { + if (stack == null) { From b41c220df164f7a261747592c298578c9e166c65 Mon Sep 17 00:00:00 2001 From: masmc05 Date: Sun, 24 Nov 2024 21:00:47 +0200 Subject: [PATCH 4/4] Update ItemStack#displayName --- patches/api/0006-Adventure.patch | 26 ++-------- .../api/0063-Add-getI18NDisplayName-API.patch | 14 ++--- .../0064-ensureServerConversions-API.patch | 10 ++-- ...0105-ItemStack-getMaxItemUseDuration.patch | 4 +- ...PI-additions-for-quantity-flags-lore.patch | 4 +- ...Add-Raw-Byte-ItemStack-Serialization.patch | 4 +- ...-Add-methods-to-get-translation-keys.patch | 4 +- ...ate-HoverEvent-from-ItemStack-Entity.patch | 4 +- .../api/0254-Improve-Item-Rarity-API.patch | 4 +- .../api/0272-ItemStack-repair-check-API.patch | 4 +- .../api/0340-Add-enchantWithLevels-API.patch | 6 +-- patches/api/0374-ItemStack-damage-API.patch | 4 +- ...proper-checking-of-empty-item-stacks.patch | 4 +- patches/api/0441-ItemStack-Tooltip-API.patch | 4 +- ...73-Proxy-ItemStack-to-CraftItemStack.patch | 8 +-- ...Levels-with-enchantment-registry-set.patch | 6 +-- patches/api/0495-DataComponent-API.patch | 4 +- .../0501-Add-ItemStack-effectiveName.patch | 52 +++++++++++++++++-- patches/server/0010-Adventure.patch | 9 +--- .../0143-ensureServerConversions-API.patch | 6 +-- .../0144-Implement-getI18NDisplayName.patch | 4 +- ...ate-HoverEvent-from-ItemStack-Entity.patch | 4 +- ...0582-Add-ItemFactory-getSpawnEgg-API.patch | 4 +- ...0673-Implement-enchantWithLevels-API.patch | 4 +- ...Levels-with-enchantment-registry-set.patch | 4 +- .../1073-Add-ItemStack-effectiveName.patch | 26 +++++++++- 26 files changed, 136 insertions(+), 91 deletions(-) diff --git a/patches/api/0006-Adventure.patch b/patches/api/0006-Adventure.patch index d3a6aae13f67..56ad11702e99 100644 --- a/patches/api/0006-Adventure.patch +++ b/patches/api/0006-Adventure.patch @@ -4361,10 +4361,10 @@ index 278259e211b926283ee6dfef6f96e11ddbcbf275..ebc14022c9ef9b0b3331ee53e96a3266 /** diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java -index aa7fcae0de70aa5c10a331dfb076efd2f2c64065..d5342258086066d3b9ef404916bad8440f0cf0cd 100644 +index aa7fcae0de70aa5c10a331dfb076efd2f2c64065..9aa91975eccd1861d12ac43a8230a731c71c5a7d 100644 --- a/src/main/java/org/bukkit/inventory/ItemFactory.java +++ b/src/main/java/org/bukkit/inventory/ItemFactory.java -@@ -200,4 +200,24 @@ public interface ItemFactory { +@@ -200,4 +200,15 @@ public interface ItemFactory { */ @NotNull ItemStack enchantItem(@NotNull final ItemStack item, final int level, final boolean allowTreasures); @@ -4378,19 +4378,10 @@ index aa7fcae0de70aa5c10a331dfb076efd2f2c64065..d5342258086066d3b9ef404916bad844 + */ + @NotNull + net.kyori.adventure.text.event.HoverEvent asHoverEvent(final @NotNull ItemStack item, final @NotNull java.util.function.UnaryOperator op); -+ -+ /** -+ * Get the formatted display name of the {@link ItemStack}. -+ * -+ * @param itemStack the {@link ItemStack} -+ * @return display name of the {@link ItemStack} -+ */ -+ @NotNull -+ net.kyori.adventure.text.Component displayName(@NotNull ItemStack itemStack); + // Paper end - Adventure } diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index eade62328895133c026e7e678e648e1fc846f5ee..730c42eddd38acec1cdbb19dfc8c675795d1e68d 100644 +index eade62328895133c026e7e678e648e1fc846f5ee..a7874ed7507af57cf39c6a295fcd95253778ed14 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java @@ -26,7 +26,7 @@ import org.jetbrains.annotations.Nullable; @@ -4402,7 +4393,7 @@ index eade62328895133c026e7e678e648e1fc846f5ee..730c42eddd38acec1cdbb19dfc8c6757 private Material type = Material.AIR; private int amount = 0; private MaterialData data = null; -@@ -626,4 +626,21 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat +@@ -626,4 +626,12 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat public String getTranslationKey() { return Bukkit.getUnsafe().getTranslationKey(this); } @@ -4413,15 +4404,6 @@ index eade62328895133c026e7e678e648e1fc846f5ee..730c42eddd38acec1cdbb19dfc8c6757 + public net.kyori.adventure.text.event.HoverEvent asHoverEvent(final @NotNull java.util.function.UnaryOperator op) { + return org.bukkit.Bukkit.getServer().getItemFactory().asHoverEvent(this, op); + } -+ -+ /** -+ * Get the formatted display name of the {@link ItemStack}. -+ * -+ * @return display name of the {@link ItemStack} -+ */ -+ public net.kyori.adventure.text.@NotNull Component displayName() { -+ return Bukkit.getServer().getItemFactory().displayName(this); -+ } + // Paper end } diff --git a/src/main/java/org/bukkit/inventory/MenuType.java b/src/main/java/org/bukkit/inventory/MenuType.java diff --git a/patches/api/0063-Add-getI18NDisplayName-API.patch b/patches/api/0063-Add-getI18NDisplayName-API.patch index ecdf3c006c65..87fb45836451 100644 --- a/patches/api/0063-Add-getI18NDisplayName-API.patch +++ b/patches/api/0063-Add-getI18NDisplayName-API.patch @@ -8,12 +8,12 @@ Currently the server only supports the English language. To override this, You must replace the language file embedded in the server jar. diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java -index d5342258086066d3b9ef404916bad8440f0cf0cd..333884bc8fe45c66d37a1bbcebc10ea655d2055f 100644 +index 9aa91975eccd1861d12ac43a8230a731c71c5a7d..0d7ac6c333776ebcc19b113590fc13b012a6faab 100644 --- a/src/main/java/org/bukkit/inventory/ItemFactory.java +++ b/src/main/java/org/bukkit/inventory/ItemFactory.java -@@ -220,4 +220,20 @@ public interface ItemFactory { +@@ -211,4 +211,20 @@ public interface ItemFactory { @NotNull - net.kyori.adventure.text.Component displayName(@NotNull ItemStack itemStack); + net.kyori.adventure.text.event.HoverEvent asHoverEvent(final @NotNull ItemStack item, final @NotNull java.util.function.UnaryOperator op); // Paper end - Adventure + + // Paper start - add getI18NDisplayName @@ -33,12 +33,12 @@ index d5342258086066d3b9ef404916bad8440f0cf0cd..333884bc8fe45c66d37a1bbcebc10ea6 + // Paper end - add getI18NDisplayName } diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index 730c42eddd38acec1cdbb19dfc8c675795d1e68d..da706fd72367b26b919ce08a5e118582020d4fbc 100644 +index a7874ed7507af57cf39c6a295fcd95253778ed14..346e7d0e59902f244d2382819f7800a5e6c7b4dd 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java -@@ -642,5 +642,20 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat - public net.kyori.adventure.text.@NotNull Component displayName() { - return Bukkit.getServer().getItemFactory().displayName(this); +@@ -633,5 +633,20 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat + public net.kyori.adventure.text.event.HoverEvent asHoverEvent(final @NotNull java.util.function.UnaryOperator op) { + return org.bukkit.Bukkit.getServer().getItemFactory().asHoverEvent(this, op); } + + /** diff --git a/patches/api/0064-ensureServerConversions-API.patch b/patches/api/0064-ensureServerConversions-API.patch index 9d1a4cb932f5..0c3b5db7a6b5 100644 --- a/patches/api/0064-ensureServerConversions-API.patch +++ b/patches/api/0064-ensureServerConversions-API.patch @@ -7,10 +7,10 @@ This will take a Bukkit ItemStack and run it through any conversions a server pr to ensure it meets latest minecraft expectations. diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java -index 333884bc8fe45c66d37a1bbcebc10ea655d2055f..c1ec8efffd5ff2a4dcb1d761be9a431a62284607 100644 +index 0d7ac6c333776ebcc19b113590fc13b012a6faab..763a21276e20f3ac20255705caf8816a906bf1ab 100644 --- a/src/main/java/org/bukkit/inventory/ItemFactory.java +++ b/src/main/java/org/bukkit/inventory/ItemFactory.java -@@ -236,4 +236,18 @@ public interface ItemFactory { +@@ -227,4 +227,18 @@ public interface ItemFactory { @Deprecated(since = "1.18.1", forRemoval = true) String getI18NDisplayName(@Nullable ItemStack item); // Paper end - add getI18NDisplayName @@ -30,7 +30,7 @@ index 333884bc8fe45c66d37a1bbcebc10ea655d2055f..c1ec8efffd5ff2a4dcb1d761be9a431a + // Paper end - ensure server conversions API } diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index da706fd72367b26b919ce08a5e118582020d4fbc..29bc12cb3095282a31f01f08ac66c15b24f42524 100644 +index 346e7d0e59902f244d2382819f7800a5e6c7b4dd..c8e00c6e5008cc8393c268ad0cf62324adec6446 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java @@ -566,7 +566,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat @@ -42,8 +42,8 @@ index da706fd72367b26b919ce08a5e118582020d4fbc..29bc12cb3095282a31f01f08ac66c15b } /** -@@ -643,6 +643,19 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat - return Bukkit.getServer().getItemFactory().displayName(this); +@@ -634,6 +634,19 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat + return org.bukkit.Bukkit.getServer().getItemFactory().asHoverEvent(this, op); } + /** diff --git a/patches/api/0105-ItemStack-getMaxItemUseDuration.patch b/patches/api/0105-ItemStack-getMaxItemUseDuration.patch index bb9d57e4e1e7..47c5c562b770 100644 --- a/patches/api/0105-ItemStack-getMaxItemUseDuration.patch +++ b/patches/api/0105-ItemStack-getMaxItemUseDuration.patch @@ -6,10 +6,10 @@ Subject: [PATCH] ItemStack#getMaxItemUseDuration Allows you to determine how long it takes to use a usable/consumable item diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index 29bc12cb3095282a31f01f08ac66c15b24f42524..f908c11ece7b3d1a52e21540999f36796237d590 100644 +index c8e00c6e5008cc8393c268ad0cf62324adec6446..1ff42a56d8b8cba6a2374725629a70c23a1c5701 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java -@@ -670,5 +670,21 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat +@@ -661,5 +661,21 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat public String getI18NDisplayName() { return Bukkit.getServer().getItemFactory().getI18NDisplayName(this); } diff --git a/patches/api/0113-ItemStack-API-additions-for-quantity-flags-lore.patch b/patches/api/0113-ItemStack-API-additions-for-quantity-flags-lore.patch index 0bfbef94ea46..aeb82774a5a5 100644 --- a/patches/api/0113-ItemStack-API-additions-for-quantity-flags-lore.patch +++ b/patches/api/0113-ItemStack-API-additions-for-quantity-flags-lore.patch @@ -5,10 +5,10 @@ Subject: [PATCH] ItemStack API additions for quantity/flags/lore diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index f908c11ece7b3d1a52e21540999f36796237d590..d125d29759167996a90b7b69d92d944e80af22ab 100644 +index 1ff42a56d8b8cba6a2374725629a70c23a1c5701..463e9550edbcc1bba1157c7b56c3f37e60f42207 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java -@@ -686,5 +686,185 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat +@@ -677,5 +677,185 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat // Requires access to NMS return ensureServerConversions().getMaxItemUseDuration(entity); } diff --git a/patches/api/0182-Add-Raw-Byte-ItemStack-Serialization.patch b/patches/api/0182-Add-Raw-Byte-ItemStack-Serialization.patch index 1d4c5dfaea57..15b3b434d4fd 100644 --- a/patches/api/0182-Add-Raw-Byte-ItemStack-Serialization.patch +++ b/patches/api/0182-Add-Raw-Byte-ItemStack-Serialization.patch @@ -22,10 +22,10 @@ index 8b5e4756d1c80e55be166dbe1faf57799f9cc03b..66d29e7f4187309d4a55202d1bda4b94 // Paper end } diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index e9c29fc1db686b80bc2477d78ec2b361b8600b9e..af09398e0864d338da530495bfd577db8adbe65a 100644 +index ef8b2cedcaf7c0076d595e275bbfe2e858986c03..8df3a5c03330d7b678f704adcbd7573d858b23ed 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java -@@ -661,6 +661,117 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat +@@ -652,6 +652,117 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat return Bukkit.getServer().getItemFactory().ensureServerConversions(this); } diff --git a/patches/api/0202-Add-methods-to-get-translation-keys.patch b/patches/api/0202-Add-methods-to-get-translation-keys.patch index 000d7769c8b3..716662fbf02b 100644 --- a/patches/api/0202-Add-methods-to-get-translation-keys.patch +++ b/patches/api/0202-Add-methods-to-get-translation-keys.patch @@ -516,7 +516,7 @@ index 5bd252c0ae3b09fe141d131360c67bb9bfbf5422..78587d9fabe6371a23a7963917b054db + } diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index af09398e0864d338da530495bfd577db8adbe65a..60eec8a12f01562678732bcf38ac407e70d74965 100644 +index 8df3a5c03330d7b678f704adcbd7573d858b23ed..e7e825f10172b54f136de54214b8d25b311ae778 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java @@ -27,7 +27,7 @@ import org.jetbrains.annotations.Nullable; @@ -536,7 +536,7 @@ index af09398e0864d338da530495bfd577db8adbe65a..60eec8a12f01562678732bcf38ac407e public String getTranslationKey() { return Bukkit.getUnsafe().getTranslationKey(this); } -@@ -982,5 +983,16 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat +@@ -973,5 +974,16 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat ItemMeta itemMeta = getItemMeta(); return itemMeta != null && itemMeta.hasItemFlag(flag); } diff --git a/patches/api/0203-Create-HoverEvent-from-ItemStack-Entity.patch b/patches/api/0203-Create-HoverEvent-from-ItemStack-Entity.patch index 27625797e0fe..0d6337201a94 100644 --- a/patches/api/0203-Create-HoverEvent-from-ItemStack-Entity.patch +++ b/patches/api/0203-Create-HoverEvent-from-ItemStack-Entity.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Create HoverEvent from ItemStack Entity diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java -index a1d8ef8eda3c0256e8c82b7a01c3e7b11454b250..579a9037b656bef9fb65c6da03611e981492074a 100644 +index d6f048fd1be9c171ad6cd9f26a7af9d4624c36f3..e244fb24975d4dfd91ca4d96e4c7ccb5f50e4a15 100644 --- a/src/main/java/org/bukkit/inventory/ItemFactory.java +++ b/src/main/java/org/bukkit/inventory/ItemFactory.java -@@ -250,4 +250,65 @@ public interface ItemFactory { +@@ -241,4 +241,65 @@ public interface ItemFactory { @NotNull ItemStack ensureServerConversions(@NotNull ItemStack item); // Paper end - ensure server conversions API diff --git a/patches/api/0254-Improve-Item-Rarity-API.patch b/patches/api/0254-Improve-Item-Rarity-API.patch index 6914d28cf844..6a2c5899cfa7 100644 --- a/patches/api/0254-Improve-Item-Rarity-API.patch +++ b/patches/api/0254-Improve-Item-Rarity-API.patch @@ -110,10 +110,10 @@ index e7931f73f10fe35ebd5fe4a04b036d53bb117ebd..cbce835ed6d44e5b8c9aaae4e36a77f8 + // Paper end } diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index 60eec8a12f01562678732bcf38ac407e70d74965..45fc5fab3817a8d9e1c83bcfb0add9eba023abfe 100644 +index e7e825f10172b54f136de54214b8d25b311ae778..9a7191b7e74d28860e7ae26e3e06acf89845bbb6 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java -@@ -994,5 +994,17 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat +@@ -985,5 +985,17 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat public @NotNull String translationKey() { return Bukkit.getUnsafe().getTranslationKey(this); } diff --git a/patches/api/0272-ItemStack-repair-check-API.patch b/patches/api/0272-ItemStack-repair-check-API.patch index 149c1f28521f..e2c7b09efb88 100644 --- a/patches/api/0272-ItemStack-repair-check-API.patch +++ b/patches/api/0272-ItemStack-repair-check-API.patch @@ -25,10 +25,10 @@ index ce9bbe4a9010ca31ace1f0b7fb67eab0f13ac97d..5015cfe26522468ac7decbf6205d654c // Paper end } diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index 45fc5fab3817a8d9e1c83bcfb0add9eba023abfe..ea50697a8dcdf87be046569b75fcc53ec870ca3e 100644 +index 9a7191b7e74d28860e7ae26e3e06acf89845bbb6..09a050067ac985bb82fc880324153f8f8d48a964 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java -@@ -1006,5 +1006,27 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat +@@ -997,5 +997,27 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat public io.papermc.paper.inventory.ItemRarity getRarity() { return io.papermc.paper.inventory.ItemRarity.valueOf(this.getItemMeta().getRarity().name()); } diff --git a/patches/api/0340-Add-enchantWithLevels-API.patch b/patches/api/0340-Add-enchantWithLevels-API.patch index 744a7aa96386..a188ad784c25 100644 --- a/patches/api/0340-Add-enchantWithLevels-API.patch +++ b/patches/api/0340-Add-enchantWithLevels-API.patch @@ -7,7 +7,7 @@ Deprecate upstream's newer and poorly implemented similar API. diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java -index 579a9037b656bef9fb65c6da03611e981492074a..e1986aea72bb1f1ba2ea76f3ba53f274b6aac899 100644 +index e244fb24975d4dfd91ca4d96e4c7ccb5f50e4a15..7a426338d5670ed4d29bd55d5cf7c3137e2d33f5 100644 --- a/src/main/java/org/bukkit/inventory/ItemFactory.java +++ b/src/main/java/org/bukkit/inventory/ItemFactory.java @@ -170,8 +170,11 @@ public interface ItemFactory { @@ -46,7 +46,7 @@ index 579a9037b656bef9fb65c6da03611e981492074a..e1986aea72bb1f1ba2ea76f3ba53f274 ItemStack enchantItem(@NotNull final ItemStack item, final int level, final boolean allowTreasures); // Paper start - Adventure -@@ -311,4 +320,22 @@ public interface ItemFactory { +@@ -302,4 +311,22 @@ public interface ItemFactory { @Deprecated net.md_5.bungee.api.chat.hover.content.Content hoverContentOf(@NotNull org.bukkit.entity.Entity entity, @NotNull net.md_5.bungee.api.chat.BaseComponent[] customName); // Paper end - bungee hover events @@ -70,7 +70,7 @@ index 579a9037b656bef9fb65c6da03611e981492074a..e1986aea72bb1f1ba2ea76f3ba53f274 + // Paper end - enchantWithLevels API } diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index 1d1731776af5f59cd9e6bd07cb3b9fab5073ef66..9b2a62dc3da6718a3e8b39b4fb8bee3781e800cb 100644 +index 7461c6c3cc3c2132613090c9227875504e6e8291..28bfdb059acaba2d8c724fba8f4eb2525ecd84c1 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java @@ -678,6 +678,24 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat diff --git a/patches/api/0374-ItemStack-damage-API.patch b/patches/api/0374-ItemStack-damage-API.patch index e48a903a6547..8088fb005907 100644 --- a/patches/api/0374-ItemStack-damage-API.patch +++ b/patches/api/0374-ItemStack-damage-API.patch @@ -66,10 +66,10 @@ index 86c5ceddc722d28261f8a6d8368400fe2731aaf0..9f3e2903c955f2a5d1b25825c49188df + // Paper end - ItemStack damage API } diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index 9b2a62dc3da6718a3e8b39b4fb8bee3781e800cb..e39c9167bd66c528c09b256f15cc6c58666f0ca0 100644 +index 28bfdb059acaba2d8c724fba8f4eb2525ecd84c1..b321e00d280253e3a42a6027f6e62b5779a88ef8 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java -@@ -1090,5 +1090,19 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat +@@ -1081,5 +1081,19 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat public boolean canRepair(@NotNull ItemStack toBeRepaired) { return Bukkit.getUnsafe().isValidRepairItemStack(toBeRepaired, this); } diff --git a/patches/api/0417-Allow-proper-checking-of-empty-item-stacks.patch b/patches/api/0417-Allow-proper-checking-of-empty-item-stacks.patch index 0fe58e036986..4e58c33d4727 100644 --- a/patches/api/0417-Allow-proper-checking-of-empty-item-stacks.patch +++ b/patches/api/0417-Allow-proper-checking-of-empty-item-stacks.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Allow proper checking of empty item stacks This adds a method to check if an item stack is empty or not. This mirrors vanilla's implementation of the same method. diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index e39c9167bd66c528c09b256f15cc6c58666f0ca0..773780811a24aa1c1591257a993e30f2d99da436 100644 +index b321e00d280253e3a42a6027f6e62b5779a88ef8..3c091386edaf09f43d52885af120bcb35a6e90a6 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java -@@ -1104,5 +1104,24 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat +@@ -1095,5 +1095,24 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat public @NotNull ItemStack damage(int amount, @NotNull org.bukkit.entity.LivingEntity livingEntity) { return livingEntity.damageItemStack(this, amount); } diff --git a/patches/api/0441-ItemStack-Tooltip-API.patch b/patches/api/0441-ItemStack-Tooltip-API.patch index a3c4cf2de9aa..ab95634e8c08 100644 --- a/patches/api/0441-ItemStack-Tooltip-API.patch +++ b/patches/api/0441-ItemStack-Tooltip-API.patch @@ -121,10 +121,10 @@ index a0b02efdb3beed93cb1656e840f24cb98f5fd555..b503b5e13c51580367d53939ad4c19a7 + @NotNull java.util.List computeTooltipLines(@NotNull ItemStack itemStack, @NotNull io.papermc.paper.inventory.tooltip.TooltipContext tooltipContext, @Nullable org.bukkit.entity.Player player); // Paper - expose itemstack tooltip lines } diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index e6c69a54e0c1dc511fe5769f869dcecb13e04ed3..49390979cc0c68b8e719f2a2ce9e7d193c747959 100644 +index 545d90cb00977432f91f8c5394e61c3090cb8d76..c4879c5a1012c2b188ad8ddfdd8a2b54d6b2d891 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java -@@ -1124,4 +1124,21 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat +@@ -1115,4 +1115,21 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat return type.isAir() || amount <= 0; } // Paper end diff --git a/patches/api/0473-Proxy-ItemStack-to-CraftItemStack.patch b/patches/api/0473-Proxy-ItemStack-to-CraftItemStack.patch index 1608d488621b..fc8f0dc22227 100644 --- a/patches/api/0473-Proxy-ItemStack-to-CraftItemStack.patch +++ b/patches/api/0473-Proxy-ItemStack-to-CraftItemStack.patch @@ -16,7 +16,7 @@ index b503b5e13c51580367d53939ad4c19a7718c22ce..307439827b401acb96f0df1cf4ef3183 + ItemStack createEmptyStack(); // Paper - proxy ItemStack } diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index 77edc2e1c5c865db7e101aaa186657ac85edfed9..6fc8bddfcabca8c363e0d9f958f0ce7bc39099f1 100644 +index 8e5c474926a9bc1df555fbf2afbd2ed1869c70d5..2dcbe3ea6b9f3816121e1812cacb1b561458d13a 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java @@ -28,10 +28,38 @@ import org.jetbrains.annotations.Nullable; @@ -412,7 +412,7 @@ index 77edc2e1c5c865db7e101aaa186657ac85edfed9..6fc8bddfcabca8c363e0d9f958f0ce7b @Override @NotNull -@@ -894,11 +834,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat +@@ -885,11 +825,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat } public int getMaxItemUseDuration(@NotNull final org.bukkit.entity.LivingEntity entity) { @@ -425,7 +425,7 @@ index 77edc2e1c5c865db7e101aaa186657ac85edfed9..6fc8bddfcabca8c363e0d9f958f0ce7b } /** -@@ -1148,7 +1084,8 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat +@@ -1139,7 +1075,8 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat */ @NotNull public static ItemStack empty() { @@ -435,7 +435,7 @@ index 77edc2e1c5c865db7e101aaa186657ac85edfed9..6fc8bddfcabca8c363e0d9f958f0ce7b } /** -@@ -1156,7 +1093,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat +@@ -1147,7 +1084,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat * it is either air or the stack has a size of 0. */ public boolean isEmpty() { diff --git a/patches/api/0488-Add-enchantWithLevels-with-enchantment-registry-set.patch b/patches/api/0488-Add-enchantWithLevels-with-enchantment-registry-set.patch index 1978c0b0738f..b302e0503aba 100644 --- a/patches/api/0488-Add-enchantWithLevels-with-enchantment-registry-set.patch +++ b/patches/api/0488-Add-enchantWithLevels-with-enchantment-registry-set.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add enchantWithLevels with enchantment registry set diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java -index e1986aea72bb1f1ba2ea76f3ba53f274b6aac899..0a814c1f65afc00034a454e3ff720d26e6c17ecc 100644 +index 7a426338d5670ed4d29bd55d5cf7c3137e2d33f5..198a2a6b5dac78e1cc65e6929ec36f8d61f9f336 100644 --- a/src/main/java/org/bukkit/inventory/ItemFactory.java +++ b/src/main/java/org/bukkit/inventory/ItemFactory.java -@@ -338,4 +338,21 @@ public interface ItemFactory { +@@ -329,4 +329,21 @@ public interface ItemFactory { */ @NotNull ItemStack enchantWithLevels(@NotNull ItemStack itemStack, @org.jetbrains.annotations.Range(from = 1, to = 30) int levels, boolean allowTreasure, @NotNull java.util.Random random); // Paper end - enchantWithLevels API @@ -31,7 +31,7 @@ index e1986aea72bb1f1ba2ea76f3ba53f274b6aac899..0a814c1f65afc00034a454e3ff720d26 + // Paper end - enchantWithLevels with tag specification } diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index 7f63a3a37eb06049bd5de10466c6dd96cb5dd4ee..b59222b8c262545d100a9fd28b3bf1d2a4cf4eb0 100644 +index 64b9b6f389ba0b0701091c93fa7b41c4f06d17bd..42b7df968492c0dd3e5a068c00c4152e5835221a 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java @@ -678,6 +678,23 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat diff --git a/patches/api/0495-DataComponent-API.patch b/patches/api/0495-DataComponent-API.patch index 5f86c0b8e6b9..6cfcb86d5685 100644 --- a/patches/api/0495-DataComponent-API.patch +++ b/patches/api/0495-DataComponent-API.patch @@ -3941,10 +3941,10 @@ index ed534fe4983873a2d5f623f0d9d5e3ce254615eb..f019d490794b49d21057820bab047e2f /** diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index b59222b8c262545d100a9fd28b3bf1d2a4cf4eb0..6e4ca7d95953a25c0aaafd35e54ef9254a1b5f0b 100644 +index 42b7df968492c0dd3e5a068c00c4152e5835221a..80103b070ed42d3ce74866cbd7594f407cdcb58a 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java -@@ -1137,4 +1137,185 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat +@@ -1128,4 +1128,185 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat return Bukkit.getUnsafe().computeTooltipLines(this, tooltipContext, player); } // Paper end - expose itemstack tooltip lines diff --git a/patches/api/0501-Add-ItemStack-effectiveName.patch b/patches/api/0501-Add-ItemStack-effectiveName.patch index 0261e59549c9..ef94e5d93f8b 100644 --- a/patches/api/0501-Add-ItemStack-effectiveName.patch +++ b/patches/api/0501-Add-ItemStack-effectiveName.patch @@ -4,14 +4,60 @@ Date: Sat, 5 Oct 2024 04:23:14 +0300 Subject: [PATCH] Add ItemStack#effectiveName +diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java +index 198a2a6b5dac78e1cc65e6929ec36f8d61f9f336..b5c167c93290cc244f9bb299028b0da341b87390 100644 +--- a/src/main/java/org/bukkit/inventory/ItemFactory.java ++++ b/src/main/java/org/bukkit/inventory/ItemFactory.java +@@ -219,6 +219,19 @@ public interface ItemFactory { + */ + @NotNull + net.kyori.adventure.text.event.HoverEvent asHoverEvent(final @NotNull ItemStack item, final @NotNull java.util.function.UnaryOperator op); ++ ++ /** ++ * Get the formatted display name of the {@link ItemStack}. ++ * ++ * @param itemStack the {@link ItemStack} ++ * @return display name of the {@link ItemStack} ++ * @deprecated Misleading name, represents the chat display name used by vanilla chat messages. ++ * @see ItemStack#chatName() ++ * @see ItemStack#effectiveName() ++ */ ++ @Deprecated ++ @NotNull ++ net.kyori.adventure.text.Component displayName(@NotNull ItemStack itemStack); + // Paper end - Adventure + + // Paper start - add getI18NDisplayName diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java -index 6e4ca7d95953a25c0aaafd35e54ef9254a1b5f0b..cb787210c1333b32566c394dcc8188be0894d147 100644 +index 80103b070ed42d3ce74866cbd7594f407cdcb58a..b14a812aca05298b0838c16941eb920bad661956 100644 --- a/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/src/main/java/org/bukkit/inventory/ItemStack.java -@@ -710,6 +710,17 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat - return Bukkit.getServer().getItemFactory().displayName(this); +@@ -701,6 +701,39 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat + return org.bukkit.Bukkit.getServer().getItemFactory().asHoverEvent(this, op); } ++ /** ++ * Get the formatted display name of the {@link ItemStack}. ++ * ++ * @return display name of the {@link ItemStack} ++ * @deprecated Misleading name, represents the chat display name used by vanilla chat messages. ++ * @see #chatName() ++ * @see #effectiveName() ++ */ ++ @Deprecated ++ public net.kyori.adventure.text.@NotNull Component displayName() { ++ return this.chatName(); ++ } ++ ++ /** ++ * Get the formatted chat display name of the {@link ItemStack}. ++ * ++ * @return chat display name of the {@link ItemStack} ++ */ ++ public net.kyori.adventure.text.@NotNull Component chatName() { ++ return this.craftDelegate.chatName(); ++ } ++ + /** + * Gets the effective name of this item stack shown to player in inventory. + * It takes into account the display name (with italics) from the item meta, diff --git a/patches/server/0010-Adventure.patch b/patches/server/0010-Adventure.patch index 07b2834d8ead..c5db1d62a510 100644 --- a/patches/server/0010-Adventure.patch +++ b/patches/server/0010-Adventure.patch @@ -4858,10 +4858,10 @@ index d89b178dc82c7e2ad6d586217c5a039688563e29..d674289b07748022b94cc6a7e6c6eb45 public String getTitle() { return this.title; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -index 6e111222e251e2f7959390e9fa0c31a163207c14..5d7e6b61102a6244c5426917c4ff280fa9e12cf1 100644 +index 6e111222e251e2f7959390e9fa0c31a163207c14..abf47285d76cd610e624891551fa7d4dd74933fe 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -@@ -209,4 +209,21 @@ public final class CraftItemFactory implements ItemFactory { +@@ -209,4 +209,16 @@ public final class CraftItemFactory implements ItemFactory { Optional> optional = (allowTreasures) ? Optional.empty() : registry.lookupOrThrow(Registries.ENCHANTMENT).get(EnchantmentTags.IN_ENCHANTING_TABLE); return CraftItemStack.asCraftMirror(EnchantmentHelper.enchantItem(source, craft.handle, level, registry, optional)); } @@ -4876,11 +4876,6 @@ index 6e111222e251e2f7959390e9fa0c31a163207c14..5d7e6b61102a6244c5426917c4ff280f + io.papermc.paper.adventure.PaperAdventure.asAdventure(CraftItemStack.unwrap(item).getComponentsPatch())) // unwrap is fine here because the components patch will be safely copied + )); + } -+ -+ @Override -+ public net.kyori.adventure.text.@org.jetbrains.annotations.NotNull Component displayName(@org.jetbrains.annotations.NotNull ItemStack itemStack) { -+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(CraftItemStack.asNMSCopy(itemStack).getDisplayName()); -+ } + // Paper end - Adventure } diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMenuType.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMenuType.java diff --git a/patches/server/0143-ensureServerConversions-API.patch b/patches/server/0143-ensureServerConversions-API.patch index 8c69d762bca7..737e6b09fe96 100644 --- a/patches/server/0143-ensureServerConversions-API.patch +++ b/patches/server/0143-ensureServerConversions-API.patch @@ -7,11 +7,11 @@ This will take a Bukkit ItemStack and run it through any conversions a server pr to ensure it meets latest minecraft expectations. diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -index 5d7e6b61102a6244c5426917c4ff280fa9e12cf1..91010267b8c4df582415a8f7cd7386723b556cc0 100644 +index abf47285d76cd610e624891551fa7d4dd74933fe..aec00b2af99de60d72c7e5350f4b1dce0b07cc3d 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -@@ -226,4 +226,12 @@ public final class CraftItemFactory implements ItemFactory { - return io.papermc.paper.adventure.PaperAdventure.asAdventure(CraftItemStack.asNMSCopy(itemStack).getDisplayName()); +@@ -221,4 +221,12 @@ public final class CraftItemFactory implements ItemFactory { + )); } // Paper end - Adventure + diff --git a/patches/server/0144-Implement-getI18NDisplayName.patch b/patches/server/0144-Implement-getI18NDisplayName.patch index 32d65af2dc9b..969d69db1384 100644 --- a/patches/server/0144-Implement-getI18NDisplayName.patch +++ b/patches/server/0144-Implement-getI18NDisplayName.patch @@ -8,10 +8,10 @@ Currently the server only supports the English language. To override this, You must replace the language file embedded in the server jar. diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -index 91010267b8c4df582415a8f7cd7386723b556cc0..b407968b111ff9cb9f428319d211e5d9c4c99138 100644 +index aec00b2af99de60d72c7e5350f4b1dce0b07cc3d..0a812214031f622360daa7b2d702abe49cc67c2b 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -@@ -234,4 +234,19 @@ public final class CraftItemFactory implements ItemFactory { +@@ -229,4 +229,19 @@ public final class CraftItemFactory implements ItemFactory { return CraftItemStack.asCraftMirror(CraftItemStack.asNMSCopy(item)); } // Paper end - ensure server conversions API diff --git a/patches/server/0401-Create-HoverEvent-from-ItemStack-Entity.patch b/patches/server/0401-Create-HoverEvent-from-ItemStack-Entity.patch index 66d23bfd33c1..31f741b3d8d3 100644 --- a/patches/server/0401-Create-HoverEvent-from-ItemStack-Entity.patch +++ b/patches/server/0401-Create-HoverEvent-from-ItemStack-Entity.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Create HoverEvent from ItemStack Entity diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -index b407968b111ff9cb9f428319d211e5d9c4c99138..cab7a3d21699605cb7fc480830d7529f70e69e88 100644 +index 0a812214031f622360daa7b2d702abe49cc67c2b..cd637600dadfcf9627afc201fe6340d91dc8e327 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -@@ -249,4 +249,44 @@ public final class CraftItemFactory implements ItemFactory { +@@ -244,4 +244,44 @@ public final class CraftItemFactory implements ItemFactory { return nms != null ? nms.getItem().getName(nms).getString() : null; } // Paper end - add getI18NDisplayName diff --git a/patches/server/0582-Add-ItemFactory-getSpawnEgg-API.patch b/patches/server/0582-Add-ItemFactory-getSpawnEgg-API.patch index ec4a572edfaf..9f3bdc4cccee 100644 --- a/patches/server/0582-Add-ItemFactory-getSpawnEgg-API.patch +++ b/patches/server/0582-Add-ItemFactory-getSpawnEgg-API.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add ItemFactory#getSpawnEgg API diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -index cab7a3d21699605cb7fc480830d7529f70e69e88..ad86ee4372e55c82968fd4fc6a65debab0092028 100644 +index cd637600dadfcf9627afc201fe6340d91dc8e327..98e6f22b7da3dec3c23b5d15587ceb093d99452d 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -9,6 +9,7 @@ import net.minecraft.core.HolderSet; @@ -16,7 +16,7 @@ index cab7a3d21699605cb7fc480830d7529f70e69e88..ad86ee4372e55c82968fd4fc6a65deba import net.minecraft.server.MinecraftServer; import net.minecraft.tags.EnchantmentTags; import net.minecraft.util.RandomSource; -@@ -289,4 +290,19 @@ public final class CraftItemFactory implements ItemFactory { +@@ -284,4 +285,19 @@ public final class CraftItemFactory implements ItemFactory { new net.md_5.bungee.api.chat.TextComponent(customName)); } // Paper end - bungee hover events diff --git a/patches/server/0673-Implement-enchantWithLevels-API.patch b/patches/server/0673-Implement-enchantWithLevels-API.patch index 45f1f704cacf..cfeaaae1c799 100644 --- a/patches/server/0673-Implement-enchantWithLevels-API.patch +++ b/patches/server/0673-Implement-enchantWithLevels-API.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Implement enchantWithLevels API diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -index ad86ee4372e55c82968fd4fc6a65debab0092028..d9eec6cff3c7c6515f4d61bf1063e7d609d4bcb3 100644 +index 98e6f22b7da3dec3c23b5d15587ceb093d99452d..b9bb22e47f90344d84e36abebf25b0520bc08a77 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -@@ -305,4 +305,47 @@ public final class CraftItemFactory implements ItemFactory { +@@ -300,4 +300,47 @@ public final class CraftItemFactory implements ItemFactory { return eggItem == null ? null : new net.minecraft.world.item.ItemStack(eggItem).asBukkitMirror(); } // Paper end - old getSpawnEgg API diff --git a/patches/server/1026-Add-enchantWithLevels-with-enchantment-registry-set.patch b/patches/server/1026-Add-enchantWithLevels-with-enchantment-registry-set.patch index 61f5aced36db..43158cd3fd1d 100644 --- a/patches/server/1026-Add-enchantWithLevels-with-enchantment-registry-set.patch +++ b/patches/server/1026-Add-enchantWithLevels-with-enchantment-registry-set.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add enchantWithLevels with enchantment registry set diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -index d9eec6cff3c7c6515f4d61bf1063e7d609d4bcb3..2f11d324ee5e8df66b65c1426e7d1a6d82990ea7 100644 +index b9bb22e47f90344d84e36abebf25b0520bc08a77..3760317ec17e4c65cc379da22ef35eed2a0a9607 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java -@@ -322,6 +322,22 @@ public final class CraftItemFactory implements ItemFactory { +@@ -317,6 +317,22 @@ public final class CraftItemFactory implements ItemFactory { ); } diff --git a/patches/server/1073-Add-ItemStack-effectiveName.patch b/patches/server/1073-Add-ItemStack-effectiveName.patch index 29fd3277bc27..61d290e6589a 100644 --- a/patches/server/1073-Add-ItemStack-effectiveName.patch +++ b/patches/server/1073-Add-ItemStack-effectiveName.patch @@ -4,16 +4,38 @@ Date: Sat, 5 Oct 2024 04:23:13 +0300 Subject: [PATCH] Add ItemStack#effectiveName +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +index 3760317ec17e4c65cc379da22ef35eed2a0a9607..75b1b28752165ee47814e553657131363c3645d1 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +@@ -221,6 +221,11 @@ public final class CraftItemFactory implements ItemFactory { + io.papermc.paper.adventure.PaperAdventure.asAdventure(CraftItemStack.unwrap(item).getComponentsPatch())) // unwrap is fine here because the components patch will be safely copied + )); + } ++ ++ @Override ++ public net.kyori.adventure.text.@org.jetbrains.annotations.NotNull Component displayName(@org.jetbrains.annotations.NotNull ItemStack itemStack) { ++ return itemStack.chatName(); ++ } + // Paper end - Adventure + + // Paper start - ensure server conversions API diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -index ccad5a7018f6eaacb011818e9da990c75e0d06df..427e0fb8e932cf401a5e0ae7c310fe338554dd27 100644 +index ccad5a7018f6eaacb011818e9da990c75e0d06df..a41bbeaa2f60a415630239ee3226c56edf259389 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java -@@ -469,6 +469,13 @@ public final class CraftItemStack extends ItemStack { +@@ -469,6 +469,19 @@ public final class CraftItemStack extends ItemStack { return true; } + // Paper start - add ItemStack#effectiveName + @Override ++ public net.kyori.adventure.text.Component chatName() { ++ net.minecraft.network.chat.Component component = this.handle == null ? net.minecraft.world.item.ItemStack.EMPTY.getDisplayName() : this.handle.getDisplayName(); ++ return io.papermc.paper.adventure.PaperAdventure.asAdventure(component); ++ } ++ ++ @Override + public net.kyori.adventure.text.Component effectiveName() { + return this.handle == null ? net.kyori.adventure.text.Component.empty() : io.papermc.paper.adventure.PaperAdventure.asAdventure(this.handle.getStyledHoverName()); + }