Paper/patches/api/0064-Add-getI18NDisplayName-API.patch

53 lines
2.2 KiB
Diff
Raw Normal View History

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: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
2021-06-12 13:18:01 +02:00
index 6cc4bad2ecd19f44a680ff03cbfb99d48ea5c337..b1fbb931148a87f29e8b8796b13851d767cc1d68 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/inventory/ItemFactory.java
+++ b/src/main/java/org/bukkit/inventory/ItemFactory.java
2021-06-12 13:18:01 +02:00
@@ -160,5 +160,16 @@ public interface ItemFactory {
2021-06-11 14:02:28 +02:00
*/
@NotNull
2021-06-12 13:18:01 +02:00
net.kyori.adventure.text.Component displayName(@NotNull ItemStack itemStack);
2021-06-11 14:02:28 +02:00
+
+ /**
+ * 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
+ */
+ @Nullable
+ String getI18NDisplayName(@Nullable ItemStack item);
// Paper end
}
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
2021-06-12 13:18:01 +02:00
index a15abec467bac70116a6fc21a300d4930b909f15..de5bcdb7b84acdd5e22500e367df292f35a86e19 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
2021-06-12 13:18:01 +02:00
@@ -611,5 +611,17 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor
public @NotNull net.kyori.adventure.text.Component displayName() {
return Bukkit.getServer().getItemFactory().displayName(this);
2021-06-11 14:02:28 +02:00
}
+
+ /**
+ * 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
+ */
+ @Nullable
+ public String getI18NDisplayName() {
+ return Bukkit.getServer().getItemFactory().getI18NDisplayName(this);
+ }
// Paper end
}