Full hex color support in admin/party chat

This commit is contained in:
nossr50
2020-11-06 15:16:26 -08:00
parent 1383457eba
commit 4abf64f625
8 changed files with 88 additions and 10 deletions

View File

@ -54,7 +54,7 @@ public class AdminChatMailer extends AbstractChatMailer {
*/
public @NotNull TextComponent addStyle(@NotNull Author author, @NotNull String message, boolean canColor) {
if(canColor) {
return TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Style.Admin", author.getAuthoredName(ChatChannel.ADMIN), LocaleLoader.addColors(message)));
return LocaleLoader.getTextComponent("Chat.Style.Admin", TextUtils.sanitizeAuthorName(author, ChatChannel.ADMIN), message);
} else {
return TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Style.Admin", author.getAuthoredName(ChatChannel.ADMIN), message));
}
@ -75,4 +75,6 @@ public class AdminChatMailer extends AbstractChatMailer {
sendMail(chatMessage);
}
}
}

View File

@ -46,13 +46,17 @@ public class PartyChatMailer extends AbstractChatMailer {
*/
public @NotNull TextComponent addStyle(@NotNull Author author, @NotNull String message, boolean canColor, boolean isLeader) {
if(canColor) {
message = LocaleLoader.addColors(message);
}
if(isLeader) {
return TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Style.Party.Leader", author.getAuthoredName(ChatChannel.PARTY), message));
if(isLeader) {
return LocaleLoader.getTextComponent("Chat.Style.Party.Leader", TextUtils.sanitizeAuthorName(author, ChatChannel.PARTY), message);
} else {
return LocaleLoader.getTextComponent("Chat.Style.Party", author.getAuthoredName(ChatChannel.PARTY), message);
}
} else {
return TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Style.Party", author.getAuthoredName(ChatChannel.PARTY), message));
if(isLeader) {
return TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Style.Party.Leader", author.getAuthoredName(ChatChannel.PARTY), message));
} else {
return TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Style.Party", author.getAuthoredName(ChatChannel.PARTY), message));
}
}
}

View File

@ -46,7 +46,7 @@ public class PartyChatMessage extends AbstractChatMessage {
//Sends to everyone but console
audience.sendMessage(author, componentMessage);
TextComponent spyMessage = TextUtils.ofLegacyTextRaw(LocaleLoader.getString("Chat.Spy.Party", author.getAuthoredName(ChatChannel.PARTY), rawMessage, party.getName()));
TextComponent spyMessage = LocaleLoader.getTextComponent("Chat.Spy.Party", TextUtils.sanitizeAuthorName(author, ChatChannel.PARTY), rawMessage, party.getName());
//Relay to spies
messagePartyChatSpies(spyMessage);