From b80827ed1eb3b6395830086fca0a59be2955d942 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 17 Jul 2022 17:12:48 +0200 Subject: [PATCH] Fix local colorcodes Signed-off-by: Lixfel --- .../bungeecore/listeners/ChatListener.java | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index a815f6a2..b632ef14 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -82,27 +82,27 @@ public class ChatListener extends BasicListener { } public static void sendChat(ChatSender sender, Stream receivers, String format, ChatSender msgReceiver, String message) { - String finalMessage = modifyFilter(sender, message); - if(finalMessage == null) + if(chatFilter(sender, message)) return; SteamwarUser user = sender.user(); + String coloredMessage = (user.getUserGroup() != UserGroup.Member || coloredTeams.contains(user.getTeam())) ? ChatColor.translateAlternateColorCodes('&', message) : message; AtomicBoolean noReceiver = new AtomicBoolean(true); receivers.filter(ChatSender::chatShown).forEach(player -> { if(sender.user().getId() != player.user().getId()) noReceiver.set(false); - chatToReciever(player, msgReceiver, user, format, finalMessage); + chatToReciever(player, msgReceiver, user, format, coloredMessage); }); - chatToReciever(ChatSender.console(), msgReceiver, user, format, finalMessage); + chatToReciever(ChatSender.console(), msgReceiver, user, format, coloredMessage); if(format.equals("CHAT_GLOBAL")) { if (SteamwarDiscordBot.instance() != null) - chatToReciever(ChatSender.discordChannel(SteamwarDiscordBot.instance().getIngameChatListener()), msgReceiver, user, format, finalMessage); + chatToReciever(ChatSender.discordChannel(SteamwarDiscordBot.instance().getIngameChatListener()), msgReceiver, user, format, coloredMessage); } else if (format.equals("CHAT_SERVERTEAM")) { if (SteamwarDiscordBot.instance() != null) - chatToReciever(ChatSender.discordChannel(SteamwarDiscordBot.instance().getServerTeamChatListener()), msgReceiver, user, format, finalMessage); + chatToReciever(ChatSender.discordChannel(SteamwarDiscordBot.instance().getServerTeamChatListener()), msgReceiver, user, format, coloredMessage); } else if (noReceiver.get()) { sender.system("CHAT_NO_RECEIVER"); } @@ -119,40 +119,35 @@ public class ChatListener extends BasicListener { if(ChatListener.filteredCommand(player, message)) return; - if(!message.startsWith("/")) { - message = modifyFilter(sender, message); - if(message == null) - return; - } + + if(!message.startsWith("/") && chatFilter(sender, message)) + return; Chat19.chat(player, message); } - private static String modifyFilter(ChatSender sender, String message) { + private static boolean chatFilter(ChatSender sender, String message) { if(!sender.chatShown()) { sender.system("CHAT_RECEIVE"); - return null; + return true; } SteamwarUser user = sender.user(); UserGroup group = user.getUserGroup(); if(!group.isTeamGroup() && (message.contains("http:") || message.contains("https:") || message.contains("www."))){ sender.system("CHAT_NO_LINKS"); - return null; + return true; } if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute)) - return null; - - if(group != UserGroup.Member || coloredTeams.contains(user.getTeam())) - message = ChatColor.translateAlternateColorCodes('&', message); + return true; if (message.contains("LIXFEL")) specialAlert(sender, "Lixfel", "CHAT_LIXFEL_", 3, 6, 11, 12, 15); if (message.contains("YOYONOW")) specialAlert(sender, "YoyoNow", "CHAT_YOYONOW_", 3, 6, 11, 12); - return message; + return false; } private static void chatToReciever(ChatSender receiver, ChatSender msgReceiver, SteamwarUser sender, String format, String message) {