SteamWar/BungeeCore
Archiviert
13
2

Fix local colorcodes
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2022-07-17 17:12:48 +02:00
Ursprung c79f49b166
Commit b80827ed1e

Datei anzeigen

@ -82,27 +82,27 @@ public class ChatListener extends BasicListener {
} }
public static void sendChat(ChatSender sender, Stream<ChatSender> receivers, String format, ChatSender msgReceiver, String message) { public static void sendChat(ChatSender sender, Stream<ChatSender> receivers, String format, ChatSender msgReceiver, String message) {
String finalMessage = modifyFilter(sender, message); if(chatFilter(sender, message))
if(finalMessage == null)
return; return;
SteamwarUser user = sender.user(); SteamwarUser user = sender.user();
String coloredMessage = (user.getUserGroup() != UserGroup.Member || coloredTeams.contains(user.getTeam())) ? ChatColor.translateAlternateColorCodes('&', message) : message;
AtomicBoolean noReceiver = new AtomicBoolean(true); AtomicBoolean noReceiver = new AtomicBoolean(true);
receivers.filter(ChatSender::chatShown).forEach(player -> { receivers.filter(ChatSender::chatShown).forEach(player -> {
if(sender.user().getId() != player.user().getId()) if(sender.user().getId() != player.user().getId())
noReceiver.set(false); 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(format.equals("CHAT_GLOBAL")) {
if (SteamwarDiscordBot.instance() != null) 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")) { } else if (format.equals("CHAT_SERVERTEAM")) {
if (SteamwarDiscordBot.instance() != null) 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()) { } else if (noReceiver.get()) {
sender.system("CHAT_NO_RECEIVER"); sender.system("CHAT_NO_RECEIVER");
} }
@ -119,40 +119,35 @@ public class ChatListener extends BasicListener {
if(ChatListener.filteredCommand(player, message)) if(ChatListener.filteredCommand(player, message))
return; return;
if(!message.startsWith("/")) {
message = modifyFilter(sender, message); if(!message.startsWith("/") && chatFilter(sender, message))
if(message == null)
return; return;
}
Chat19.chat(player, message); Chat19.chat(player, message);
} }
private static String modifyFilter(ChatSender sender, String message) { private static boolean chatFilter(ChatSender sender, String message) {
if(!sender.chatShown()) { if(!sender.chatShown()) {
sender.system("CHAT_RECEIVE"); sender.system("CHAT_RECEIVE");
return null; return true;
} }
SteamwarUser user = sender.user(); SteamwarUser user = sender.user();
UserGroup group = user.getUserGroup(); UserGroup group = user.getUserGroup();
if(!group.isTeamGroup() && (message.contains("http:") || message.contains("https:") || message.contains("www."))){ if(!group.isTeamGroup() && (message.contains("http:") || message.contains("https:") || message.contains("www."))){
sender.system("CHAT_NO_LINKS"); sender.system("CHAT_NO_LINKS");
return null; return true;
} }
if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute)) if (user.isPunishedWithMessage(sender, Punishment.PunishmentType.Mute))
return null; return true;
if(group != UserGroup.Member || coloredTeams.contains(user.getTeam()))
message = ChatColor.translateAlternateColorCodes('&', message);
if (message.contains("LIXFEL")) if (message.contains("LIXFEL"))
specialAlert(sender, "Lixfel", "CHAT_LIXFEL_", 3, 6, 11, 12, 15); specialAlert(sender, "Lixfel", "CHAT_LIXFEL_", 3, 6, 11, 12, 15);
if (message.contains("YOYONOW")) if (message.contains("YOYONOW"))
specialAlert(sender, "YoyoNow", "CHAT_YOYONOW_", 3, 6, 11, 12); 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) { private static void chatToReciever(ChatSender receiver, ChatSender msgReceiver, SteamwarUser sender, String format, String message) {