SPIGOT-4177: Change behaviour of item display names yet again

This commit is contained in:
md_5 2018-07-29 09:24:42 +10:00
parent ff9bab10b5
commit 6a1dc5bb7d
2 changed files with 6 additions and 2 deletions

View File

@ -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

View File

@ -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];
}