From 48f228173eb55b321f1ab321259d1e5dbb97b54f Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sun, 16 Jan 2022 16:53:26 -0800 Subject: [PATCH] Fix and deprecate ItemStack#getI18NDisplayName (#7358) --- patches/api/Add-getI18NDisplayName-API.patch | 6 ++++++ patches/api/ensureServerConversions-API.patch | 2 +- .../server/Create-HoverEvent-from-ItemStack-Entity.patch | 2 +- patches/server/Implement-getI18NDisplayName.patch | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/patches/api/Add-getI18NDisplayName-API.patch b/patches/api/Add-getI18NDisplayName-API.patch index bc3a4e72e8..4690b6073d 100644 --- a/patches/api/Add-getI18NDisplayName-API.patch +++ b/patches/api/Add-getI18NDisplayName-API.patch @@ -23,8 +23,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @param item Item to return Display name of + * @return Display name of Item ++ * @deprecated {@link ItemStack} implements {@link net.kyori.adventure.translation.Translatable}; use that and ++ * {@link net.kyori.adventure.text.Component#translatable(net.kyori.adventure.translation.Translatable)} instead. + */ + @Nullable ++ @Deprecated + String getI18NDisplayName(@Nullable ItemStack item); // Paper end } @@ -43,8 +46,11 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * You must replace the language file embedded in the server jar. + * + * @return Display name of Item ++ * @deprecated {@link ItemStack} implements {@link net.kyori.adventure.translation.Translatable}; use that and ++ * {@link net.kyori.adventure.text.Component#translatable(net.kyori.adventure.translation.Translatable)} instead. + */ + @Nullable ++ @Deprecated + public String getI18NDisplayName() { + return Bukkit.getServer().getItemFactory().getI18NDisplayName(this); + } diff --git a/patches/api/ensureServerConversions-API.patch b/patches/api/ensureServerConversions-API.patch index 374584c2b8..6a9cb2dae9 100644 --- a/patches/api/ensureServerConversions-API.patch +++ b/patches/api/ensureServerConversions-API.patch @@ -11,8 +11,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/inventory/ItemFactory.java +++ b/src/main/java/org/bukkit/inventory/ItemFactory.java @@ -0,0 +0,0 @@ public interface ItemFactory { - */ @Nullable + @Deprecated String getI18NDisplayName(@Nullable ItemStack item); + + /** diff --git a/patches/server/Create-HoverEvent-from-ItemStack-Entity.patch b/patches/server/Create-HoverEvent-from-ItemStack-Entity.patch index bcf162d1b9..7a2c7c4b03 100644 --- a/patches/server/Create-HoverEvent-from-ItemStack-Entity.patch +++ b/patches/server/Create-HoverEvent-from-ItemStack-Entity.patch @@ -10,7 +10,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -0,0 +0,0 @@ public final class CraftItemFactory implements ItemFactory { - return nms != null ? net.minecraft.locale.Language.getInstance().getOrDefault(nms.getItem().getDescriptionId()) : null; + return nms != null ? net.minecraft.locale.Language.getInstance().getOrDefault(nms.getItem().getDescriptionId(nms)) : null; } + + @Override diff --git a/patches/server/Implement-getI18NDisplayName.patch b/patches/server/Implement-getI18NDisplayName.patch index 17719821ea..f8fc98f589 100644 --- a/patches/server/Implement-getI18NDisplayName.patch +++ b/patches/server/Implement-getI18NDisplayName.patch @@ -26,7 +26,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + nms = CraftItemStack.asNMSCopy(item); + } + -+ return nms != null ? net.minecraft.locale.Language.getInstance().getOrDefault(nms.getItem().getDescriptionId()) : null; ++ return nms != null ? net.minecraft.locale.Language.getInstance().getOrDefault(nms.getItem().getDescriptionId(nms)) : null; + } // Paper end }