aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-API-Patches/0062-Add-getI18NDisplayName-API.patch
blob: a655a8a501e288d96adff3c3391b6ffa919dab4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
index 30ab5d38197bccfc06f6f5554b162f8bdbfe2a45..3578f491a053154789ad696e93c70fdde74912e6 100644
--- a/src/main/java/org/bukkit/inventory/ItemFactory.java
+++ b/src/main/java/org/bukkit/inventory/ItemFactory.java
@@ -163,5 +163,16 @@ public interface ItemFactory {
      */
     @NotNull
     ItemStack ensureServerConversions(@NotNull ItemStack item);
+
+    /**
+     * 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
index c31f667c466ba80bd88ae560d14dbd18a84118b4..77d6b2ed68d8ce30b5cadb156941d2d1f7dcf5b1 100644
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
@@ -615,5 +615,17 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, net.kyor
     public ItemStack ensureServerConversions() {
         return Bukkit.getServer().getItemFactory().ensureServerConversions(this);
     }
+
+    /**
+     * 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
 }