diff options
author | md_5 <git@md-5.net> | 2018-07-29 09:24:42 +1000 |
---|---|---|
committer | md_5 <git@md-5.net> | 2018-07-29 09:24:42 +1000 |
commit | 6a1dc5bb7d967c1099ef894ebac5271a5e658999 (patch) | |
tree | 1f1d6798feb3556fc7c29576aabe132540643273 /src/main/java/org | |
parent | ff9bab10b563b07e2ad371bebde0ec7f03b96776 (diff) | |
download | craftbukkit-6a1dc5bb7d967c1099ef894ebac5271a5e658999.tar craftbukkit-6a1dc5bb7d967c1099ef894ebac5271a5e658999.tar.gz craftbukkit-6a1dc5bb7d967c1099ef894ebac5271a5e658999.tar.lz craftbukkit-6a1dc5bb7d967c1099ef894ebac5271a5e658999.tar.xz craftbukkit-6a1dc5bb7d967c1099ef894ebac5271a5e658999.zip |
SPIGOT-4177: Change behaviour of item display names yet again
Diffstat (limited to 'src/main/java/org')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java | 4 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java index f47a3623..6623ae12 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java @@ -566,7 +566,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { } public final void setDisplayName(String name) { - this.displayName = (name == null) ? null : new ChatComponentText(name); + this.displayName = CraftChatMessage.wrapOrNull(name); } public boolean hasDisplayName() { @@ -580,7 +580,7 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable { @Override public void setLocalizedName(String name) { - this.locName = (name == null) ? null : new ChatComponentText(name); + this.locName = CraftChatMessage.wrapOrNull(name); } @Override diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java index 9b62ed43..299b9a28 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftChatMessage.java @@ -138,6 +138,10 @@ public final class CraftChatMessage { } } + public static IChatBaseComponent wrapOrNull(String message) { + return (message == null || message.isEmpty()) ? null : new ChatComponentText(message); + } + public static IChatBaseComponent fromStringOrNull(String message) { return (message == null || message.isEmpty()) ? null : fromString(message)[0]; } |