mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
44 lines
2.1 KiB
Diff
44 lines
2.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
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 f06452538f45e2430611aad54d060e040b32bb58..67f5448d0a03c1e018f71bdb76610a85867cc0b8 100644
|
|
--- a/src/main/java/net/minecraft/locale/Language.java
|
|
+++ b/src/main/java/net/minecraft/locale/Language.java
|
|
@@ -107,6 +107,7 @@ public abstract class Language {
|
|
instance = language;
|
|
}
|
|
|
|
+ @Deprecated 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 0bf6c27fdcc2a4342c68441670244cabf40f8e7e..6ec39de514ceed7e5ffe9a8dc94c2ffd2902cd98 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
|
@@ -355,5 +355,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.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().getOrDefault(nms.getItem().getDescriptionId()) : null;
|
|
+ }
|
|
// Paper end
|
|
}
|