SteamWar/BungeeCore
Archiviert
13
2

Merge pull request 'Fix local colorcodes' (#413) from colorFix into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #413
Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Lixfel 2022-07-17 17:42:44 +02:00
Commit 621c95b525
3 geänderte Dateien mit 22 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -82,27 +82,26 @@ public class ChatListener extends BasicListener {
}
public static void sendChat(ChatSender sender, Stream<ChatSender> receivers, String format, ChatSender msgReceiver, String message) {
String finalMessage = modifyFilter(sender, message);
if(finalMessage == null)
return;
SteamwarUser user = sender.user();
final String coloredMessage = (user.getUserGroup() != UserGroup.Member || coloredTeams.contains(user.getTeam())) ? ChatColor.translateAlternateColorCodes('&', message) : message;
if(chatFilter(sender, coloredMessage))
return;
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 +118,40 @@ 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;
}
if(message.replace("§[a-f0-9klmno]", "").trim().isEmpty()) {
sender.system("CHAT_EMPTY");
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) {

Datei anzeigen

@ -521,6 +521,7 @@ CHAT_RECEIVE=§cTo be able to send chat messages, you must also receive them!
CHAT_NO_LINKS=§cYou may not send links.
CHAT_BC_USAGE=§8/§7bc §8[§emessage§8]
CHAT_NO_RECEIVER=§cNobody receives your message
CHAT_EMPTY=§cDon't write meaningless empty messages.
CHAT_SERVERTEAM=§8STC §e{0}§8» §f{2}
CHAT_GLOBAL={3}{4}{5}{6}{0}§8» {7}{2}

Datei anzeigen

@ -500,6 +500,7 @@ CHAT_RECEIVE=§cUm Chatnachrichten versenden zu können, musst du auch welche em
CHAT_NO_LINKS=§cDu darfst keine Links versenden.
CHAT_BC_USAGE=§8/§7bc §8[§eNachricht§8]
CHAT_NO_RECEIVER=§cNiemand empfängt deine Nachricht
CHAT_EMPTY=§cSchreibe keine inhaltslosen Nachrichten.
CHAT_SERVERTEAM=§8STC §e{0}§8» §f{2}
CHAT_GLOBAL={3}{4}{5}{6}{0}§8» {7}{2}