From ea1b1d04b7b63a7d190741e8c543e0fc8b4adfca Mon Sep 17 00:00:00 2001 From: Darkknights22 Date: Sun, 23 Oct 2022 22:08:24 +0100 Subject: [PATCH] Add ability to change party chat colour --- .../java/com/gmail/nossr50/chat/mailer/PartyChatMailer.java | 4 +++- src/main/java/com/gmail/nossr50/config/ChatConfig.java | 6 ++++++ src/main/resources/chat.yml | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/chat/mailer/PartyChatMailer.java b/src/main/java/com/gmail/nossr50/chat/mailer/PartyChatMailer.java index 6158ad826..c77aa1088 100644 --- a/src/main/java/com/gmail/nossr50/chat/mailer/PartyChatMailer.java +++ b/src/main/java/com/gmail/nossr50/chat/mailer/PartyChatMailer.java @@ -3,6 +3,7 @@ package com.gmail.nossr50.chat.mailer; import com.gmail.nossr50.chat.author.Author; import com.gmail.nossr50.chat.message.ChatMessage; import com.gmail.nossr50.chat.message.PartyChatMessage; +import com.gmail.nossr50.config.ChatConfig; import com.gmail.nossr50.datatypes.chat.ChatChannel; import com.gmail.nossr50.datatypes.party.Party; import com.gmail.nossr50.events.chat.McMMOChatEvent; @@ -31,7 +32,8 @@ public class PartyChatMailer extends AbstractChatMailer { * @param canColor whether or not the author can use colors in chat */ public void processChatMessage(@NotNull Author author, @NotNull String rawString, @NotNull Party party, boolean isAsync, boolean canColor, boolean isLeader) { - PartyChatMessage chatMessage = new PartyChatMessage(pluginRef, author, constructPartyAudience(party), rawString, addStyle(author, rawString, canColor, isLeader), party); + String coloredMessage = ChatConfig.getInstance().colorChatMessage(rawString); + PartyChatMessage chatMessage = new PartyChatMessage(pluginRef, author, constructPartyAudience(party), rawString, addStyle(author, coloredMessage, canColor, isLeader), party); McMMOChatEvent chatEvent = new McMMOPartyChatEvent(pluginRef, chatMessage, party, isAsync); Bukkit.getPluginManager().callEvent(chatEvent); diff --git a/src/main/java/com/gmail/nossr50/config/ChatConfig.java b/src/main/java/com/gmail/nossr50/config/ChatConfig.java index bbda1b69c..5bfd65d59 100644 --- a/src/main/java/com/gmail/nossr50/config/ChatConfig.java +++ b/src/main/java/com/gmail/nossr50/config/ChatConfig.java @@ -2,6 +2,7 @@ package com.gmail.nossr50.config; import com.gmail.nossr50.datatypes.chat.ChatChannel; import com.gmail.nossr50.util.text.StringUtils; +import org.bukkit.ChatColor; import org.jetbrains.annotations.NotNull; public class ChatConfig extends BukkitConfig { @@ -51,6 +52,11 @@ public class ChatConfig extends BukkitConfig { return config.getBoolean(key, true); } + public String colorChatMessage(String message) { + return ChatColor.translateAlternateColorCodes('&', + config.getString("Chat.Channels.Party.Chat_Color", "&f") + message); + } + public boolean isSpyingAutomatic() { return config.getBoolean("Chat.Channels.Party.Spies.Automatically_Enable_Spying", false); } diff --git a/src/main/resources/chat.yml b/src/main/resources/chat.yml index 6fa5ecf88..c32fe90ab 100644 --- a/src/main/resources/chat.yml +++ b/src/main/resources/chat.yml @@ -6,6 +6,7 @@ Chat: Party: # Enable or disable party chat Enable: true + Chat_Color: ''&f' # Whether or not to use the current display name of a player Use_Display_Names: true Spies: