From 9a7cdcec39a287942113402ef8036e3ea2361312 Mon Sep 17 00:00:00 2001 From: Aikar Date: Wed, 26 Jul 2017 23:44:09 -0400 Subject: [PATCH] Add getI18NDisplayName API Gets the Display name as seen in the Client. Currently the server only supports the English language. To override this, You must replace the language file embedded in the server jar. --- .../0064-Add-getI18NDisplayName-API.patch | 53 +++++++++++++++++++ .../0227-Implement-getI18NDisplayName.patch | 35 ++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 Spigot-API-Patches/0064-Add-getI18NDisplayName-API.patch create mode 100644 Spigot-Server-Patches/0227-Implement-getI18NDisplayName.patch diff --git a/Spigot-API-Patches/0064-Add-getI18NDisplayName-API.patch b/Spigot-API-Patches/0064-Add-getI18NDisplayName-API.patch new file mode 100644 index 0000000000..6c560f7ef7 --- /dev/null +++ b/Spigot-API-Patches/0064-Add-getI18NDisplayName-API.patch @@ -0,0 +1,53 @@ +From f7de0db935ac36012247b83c4576cf07317891fb Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Wed, 4 May 2016 23:55:48 -0400 +Subject: [PATCH] Add getI18NDisplayName API + +Gets the Display name as seen in the Client. +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 99b90629..559de54e 100644 +--- a/src/main/java/org/bukkit/inventory/ItemFactory.java ++++ b/src/main/java/org/bukkit/inventory/ItemFactory.java +@@ -133,5 +133,15 @@ public interface ItemFactory { + * @return A potentially Data Converted ItemStack + */ + ItemStack ensureServerConversions(ItemStack item); ++ ++ /** ++ * Gets the Display name as seen in the Client. ++ * Currently the server only supports the English language. To override this, ++ * You must replace the language file embedded in the server jar. ++ * ++ * @param item Item to return Display name of ++ * @return Display name of Item ++ */ ++ String getI18NDisplayName(ItemStack item); + // Paper end + } +diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java +index 6bb19b9d..7a52da9b 100644 +--- a/src/main/java/org/bukkit/inventory/ItemStack.java ++++ b/src/main/java/org/bukkit/inventory/ItemStack.java +@@ -621,5 +621,16 @@ public class ItemStack implements Cloneable, ConfigurationSerializable { + public ItemStack ensureServerConversions() { + return Bukkit.getServer().getItemFactory().ensureServerConversions(this); + } ++ ++ /** ++ * Gets the Display name as seen in the Client. ++ * Currently the server only supports the English language. To override this, ++ * You must replace the language file embedded in the server jar. ++ * ++ * @return Display name of Item ++ */ ++ public String getI18NDisplayName() { ++ return Bukkit.getServer().getItemFactory().getI18NDisplayName(this); ++ } + // Paper end + } +-- +2.13.0 + diff --git a/Spigot-Server-Patches/0227-Implement-getI18NDisplayName.patch b/Spigot-Server-Patches/0227-Implement-getI18NDisplayName.patch new file mode 100644 index 0000000000..a841811def --- /dev/null +++ b/Spigot-Server-Patches/0227-Implement-getI18NDisplayName.patch @@ -0,0 +1,35 @@ +From a17ae8db76e8404865098e506a9377d174982c97 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Wed, 4 May 2016 23:59:38 -0400 +Subject: [PATCH] Implement getI18NDisplayName + +Gets the Display name as seen in the Client. +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 eb6987338..c2f26577c 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +@@ -200,5 +200,18 @@ public final class CraftItemFactory implements ItemFactory { + public ItemStack ensureServerConversions(ItemStack item) { + return CraftItemStack.asCraftMirror(CraftItemStack.asNMSCopy(item)); + } ++ ++ @Override ++ public String getI18NDisplayName(ItemStack item) { ++ net.minecraft.server.ItemStack nms = null; ++ if (item instanceof CraftItemStack) { ++ nms = ((CraftItemStack) item).handle; ++ } ++ if (nms == null) { ++ nms = CraftItemStack.asNMSCopy(item); ++ } ++ ++ return nms != null ? nms.getName() : null; ++ } + // Paper end + } +-- +2.13.0 +