3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-24 15:20:11 +01:00
Paper/patches/server/0150-Implement-getI18NDisplayName.patch

45 Zeilen
2.1 KiB
Diff

2021-06-11 14:02:28 +02:00
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
2021-06-12 13:18:01 +02:00
index f06452538f45e2430611aad54d060e040b32bb58..67f5448d0a03c1e018f71bdb76610a85867cc0b8 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/locale/Language.java
+++ b/src/main/java/net/minecraft/locale/Language.java
2021-06-12 13:18:01 +02:00
@@ -107,6 +107,7 @@ public abstract class Language {
instance = language;
2021-06-11 14:02:28 +02:00
}
2021-06-12 13:18:01 +02:00
+ @Deprecated public String translateKey(String key) { return getOrDefault(key); } // Paper - OBFHELPER
2021-06-11 14:02:28 +02:00
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
2021-06-12 13:18:01 +02:00
index 0bf6c27fdcc2a4342c68441670244cabf40f8e7e..6ec39de514ceed7e5ffe9a8dc94c2ffd2902cd98 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
2021-06-12 13:18:01 +02:00
@@ -355,5 +355,18 @@ public final class CraftItemFactory implements ItemFactory {
2021-06-11 14:02:28 +02:00
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);
+ }
+
2021-06-12 13:18:01 +02:00
+ return nms != null ? net.minecraft.locale.Language.getInstance().getOrDefault(nms.getItem().getDescriptionId()) : null;
2021-06-11 14:02:28 +02:00
+ }
// Paper end
}