From 15f31ef55d10b39dfdd18a1490d6c42b8d5fbf8a Mon Sep 17 00:00:00 2001 From: Draycia Date: Tue, 17 Nov 2020 04:37:20 -0800 Subject: [PATCH] Fix displayname placeholder and add nickname/username --- .../channels/impls/CarbonChatChannel.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/draycia/carbon/channels/impls/CarbonChatChannel.java b/src/main/java/net/draycia/carbon/channels/impls/CarbonChatChannel.java index cc195fc6..e8c1d3ec 100644 --- a/src/main/java/net/draycia/carbon/channels/impls/CarbonChatChannel.java +++ b/src/main/java/net/draycia/carbon/channels/impls/CarbonChatChannel.java @@ -130,16 +130,17 @@ public class CarbonChatChannel extends ChatChannel { final String displayName; - if (user.nickname() != null) { - displayName = user.nickname(); + if (user.online()) { + displayName = user.player().getDisplayName(); } else { - if (user.online()) { - displayName = user.player().getDisplayName(); - } else { - displayName = user.offlinePlayer().getName(); - } + displayName = user.offlinePlayer().getName(); } + final String offlinePlayerName = user.offlinePlayer().getName(); + + final String nickname = user.nickname() == null ? "" : user.nickname(); + final String username = offlinePlayerName == null ? "" : offlinePlayerName; + // Iterate through players who should receive messages in this channel for (final ChatUser target : recipients) { // Call second format event. Used for relational stuff (placeholders etc) @@ -157,6 +158,8 @@ public class CarbonChatChannel extends ChatChannel { TextComponent formatComponent = (TextComponent) this.carbonChat.adventureManager().processMessage(formatEvent.format(), "br", "\n", "displayname", displayName, + "nickname", nickname, + "username", username, "color", "<" + targetColor.asHexString() + ">", "phase", Long.toString(System.currentTimeMillis() % 25), "server", this.carbonChat.getConfig().getString("server-name", "Server"), @@ -187,6 +190,8 @@ public class CarbonChatChannel extends ChatChannel { final TextComponent consoleFormat = (TextComponent) this.carbonChat.adventureManager().processMessage(consoleFormatEvent.format(), "br", "\n", "displayname", displayName, + "nickname", nickname, + "username", username, "color", "<" + targetColor.asHexString() + ">", "phase", Long.toString(System.currentTimeMillis() % 25), "server", this.carbonChat.getConfig().getString("server-name", "Server"),