From 0000000000000000000000000000000000000000 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/net/minecraft/locale/Language.java b/src/main/java/net/minecraft/locale/Language.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/locale/Language.java +++ b/src/main/java/net/minecraft/locale/Language.java @@ -0,0 +0,0 @@ public abstract class Language { private static Language loadDefault() { Builder builder = ImmutableMap.builder(); - BiConsumer biconsumer = builder::put; + BiConsumer biconsumer = builder::put; // Paper - decompile fix try { InputStream inputstream = Language.class.getResourceAsStream("/assets/minecraft/lang/en_us.json"); @@ -0,0 +0,0 @@ public abstract class Language { } + public static Language getInstance() { return getInstance(); } // Paper - OBFHELPER public static Language getInstance() { return Language.instance; } + public String translateKey(String key) { return getOrDefault(key); } // Paper - OBFHELPER public abstract String getOrDefault(String key); public abstract boolean has(String key); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java @@ -0,0 +0,0 @@ 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.world.item.ItemStack nms = null; + if (item instanceof CraftItemStack) { + nms = ((CraftItemStack) item).handle; + } + if (nms == null) { + nms = CraftItemStack.asNMSCopy(item); + } + + return nms != null ? net.minecraft.locale.Language.getInstance().translateKey(nms.getItem().getDescriptionId()) : null; + } // Paper end }