Archiviert
1
0

Fix msg, tp etc.

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2022-04-22 15:44:42 +02:00
Ursprung 6a7b0ff9c1
Commit f1f334a750
6 geänderte Dateien mit 15 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -57,7 +57,7 @@ public class DiscordChatListener extends BasicDiscordListener {
if (steamwarUser == null || event.getMessage().getContentRaw().length() > 250 || steamwarUser.isPunished(Punishment.PunishmentType.Ban)) {
event.getMessage().delete().queue();
} else {
ChatListener.sendChat(ChatSender.of(event.getMessage(), steamwarUser), targets.get(), format, event.getMessage().getContentDisplay().replace('§', '&').replace('\n', ' '));
ChatListener.sendChat(ChatSender.of(event.getMessage(), steamwarUser), targets.get(), format, null, event.getMessage().getContentDisplay().replace('§', '&').replace('\n', ' '));
}
}

Datei anzeigen

@ -63,7 +63,8 @@ public class MsgCommand extends BasicCommand {
return;
}
ChatListener.sendChat(sender, Stream.of(sender, ChatSender.of(target)), "CHAT_MSG", String.join(" ", args));
ChatSender receiver = ChatSender.of(target);
ChatListener.sendChat(sender, Stream.of(sender, receiver), "CHAT_MSG", receiver, String.join(" ", args));
lastChats.put(player, target);
lastChats.put(target, player);
}

Datei anzeigen

@ -37,6 +37,6 @@ public class ServerTeamchatCommand extends BasicCommand {
return;
}
ChatListener.sendChat(sender, ChatSender.serverteamReceivers(), "CHAT_SERVERTEAM", String.join(" ", args));
ChatListener.sendChat(sender, ChatSender.serverteamReceivers(), "CHAT_SERVERTEAM", null, String.join(" ", args));
}
}

Datei anzeigen

@ -44,6 +44,6 @@ public class TeamchatCommand extends BasicCommand {
return;
}
ChatListener.sendChat(sender, ChatSender.allReceivers().filter(player -> player.user().getTeam() == user.getTeam()), "CHAT_TEAM", String.join(" ", args));
ChatListener.sendChat(sender, ChatSender.allReceivers().filter(player -> player.user().getTeam() == user.getTeam()), "CHAT_TEAM", null, String.join(" ", args));
}
}

Datei anzeigen

@ -57,7 +57,7 @@ public class TpCommand extends BasicCommand {
//Give control of teleport command to server
if(server == null) {
player.chat("/teleport " + String.join(" ", args));
player.chat("/tp " + String.join(" ", args));
return;
}

Datei anzeigen

@ -74,12 +74,12 @@ public class ChatListener extends BasicListener {
} else if (message.startsWith("+")) {
localChat(player, message.substring(1));
} else {
sendChat(ChatSender.of(player), ChatSender.globalReceivers(), "CHAT_GLOBAL", message);
sendChat(ChatSender.of(player), ChatSender.globalReceivers(), "CHAT_GLOBAL", null, message);
}
}
}
public static void sendChat(ChatSender sender, Stream<ChatSender> receivers, String format, String message) {
public static void sendChat(ChatSender sender, Stream<ChatSender> receivers, String format, ChatSender msgReceiver, String message) {
String finalMessage = modifyFilter(sender, message);
if(finalMessage == null)
return;
@ -90,17 +90,17 @@ public class ChatListener extends BasicListener {
receivers.filter(ChatSender::chatShown).forEach(player -> {
if(sender.user().getId() != player.user().getId())
noReceiver.set(false);
chatToReciever(player, user, format, finalMessage);
chatToReciever(player, msgReceiver, user, format, finalMessage);
});
chatToReciever(ChatSender.console(), user, format, finalMessage);
chatToReciever(ChatSender.console(), msgReceiver, user, format, finalMessage);
if(format.equals("CHAT_GLOBAL")) {
if (SteamwarDiscordBot.instance() != null)
chatToReciever(ChatSender.discordChannel(SteamwarDiscordBot.instance().getIngameChatListener()), user, format, finalMessage);
chatToReciever(ChatSender.discordChannel(SteamwarDiscordBot.instance().getIngameChatListener()), msgReceiver, user, format, finalMessage);
} else if (format.equals("CHAT_SERVERTEAM")) {
if (SteamwarDiscordBot.instance() != null)
chatToReciever(ChatSender.discordChannel(SteamwarDiscordBot.instance().getServerTeamChatListener()), user, format, finalMessage);
chatToReciever(ChatSender.discordChannel(SteamwarDiscordBot.instance().getServerTeamChatListener()), msgReceiver, user, format, finalMessage);
} else if (noReceiver.get()) {
sender.system("CHAT_NO_RECEIVER");
}
@ -153,16 +153,16 @@ public class ChatListener extends BasicListener {
return message;
}
private static void chatToReciever(ChatSender receiver, SteamwarUser sender, String format, String message) {
private static void chatToReciever(ChatSender receiver, ChatSender msgReceiver, SteamwarUser sender, String format, String message) {
UserGroup group = sender.getUserGroup();
receiver.chat(new Message(format,
sender,
receiver,
msgReceiver == null ? receiver : msgReceiver,
highlightMentions(message, group.getChatColorCode(), receiver),
sender.getTeam() == 0 ? "" : "§" + Team.get(sender.getTeam()).getTeamColor() + Team.get(sender.getTeam()).getTeamKuerzel() + " ",
UserElo.getEmblem(sender),
group.getColorCode(),
group.getChatPrefix() + " ",
group.getChatPrefix().length() == 0 ? "" : group.getChatPrefix() + " ",
group.getChatColorCode()));
}