59 lines
2.6 KiB
Diff
59 lines
2.6 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 8a0d2e510aee160ec3a817fd72c23bc9dfeb6287..756b78a7dc3d3e76dc0a37375b304db0b6ecf684 100644
|
|
--- a/src/main/java/net/minecraft/locale/Language.java
|
|
+++ b/src/main/java/net/minecraft/locale/Language.java
|
|
@@ -30,7 +30,7 @@ public abstract class Language {
|
|
|
|
private static Language loadDefault() {
|
|
Builder<String, String> builder = ImmutableMap.builder();
|
|
- BiConsumer biconsumer = builder::put;
|
|
+ BiConsumer<String, String> biconsumer = builder::put; // Paper - decompile fix
|
|
|
|
try {
|
|
InputStream inputstream = Language.class.getResourceAsStream("/assets/minecraft/lang/en_us.json");
|
|
@@ -87,10 +87,12 @@ 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 41c8bbf93039add43695a52d2bfc0c2cef88463d..746755f76ae177b2eeccf66f8cd95e6ffd5acad9 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
|
@@ -352,5 +352,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().translateKey(nms.getItem().getDescriptionId()) : null;
|
|
+ }
|
|
// Paper end
|
|
}
|