Add ItemStack#displayName to get the formatted display name of an ItemStack (#5628)

The display name includes formatting such as item hover event, display name (in italics if renamed in anvil), and color based on rarity.

This is what vanilla uses for give command feedback, and when an item is shown in a death message.
This commit is contained in:
Jason
2021-05-12 23:16:33 -07:00
committed by GitHub
parent 4efe8b498b
commit 453c7f05c7
13 changed files with 72 additions and 37 deletions

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Create HoverEvent from ItemStack Entity
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
index e6c818d32713d9fb0f02a46696bd8a5dabe2a3ae..6966b9d1ce674232d3f867798fa58bd0933ff69e 100644
index 910c6109783dfef86e127a0a5b7d7d3865150d89..347c23d4b7d47198f214c3f95354e8abb660b191 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
@@ -360,5 +360,40 @@ public final class CraftItemFactory implements ItemFactory {
@@ -365,5 +365,40 @@ public final class CraftItemFactory implements ItemFactory {
return nms != null ? net.minecraft.locale.LocaleLanguage.getInstance().translateKey(nms.getItem().getName()) : null;
}