From f1f334a750e8611ccdb9f8cb8066dfcff61285d2 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 22 Apr 2022 15:44:42 +0200 Subject: [PATCH] Fix msg, tp etc. Signed-off-by: Lixfel --- .../bot/listeners/DiscordChatListener.java | 2 +- .../bungeecore/commands/MsgCommand.java | 3 ++- .../commands/ServerTeamchatCommand.java | 2 +- .../bungeecore/commands/TeamchatCommand.java | 2 +- .../bungeecore/commands/TpCommand.java | 2 +- .../bungeecore/listeners/ChatListener.java | 18 +++++++++--------- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java b/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java index 5317b7b..70004ac 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java @@ -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', ' ')); } } diff --git a/src/de/steamwar/bungeecore/commands/MsgCommand.java b/src/de/steamwar/bungeecore/commands/MsgCommand.java index 09c7cdb..0107b78 100644 --- a/src/de/steamwar/bungeecore/commands/MsgCommand.java +++ b/src/de/steamwar/bungeecore/commands/MsgCommand.java @@ -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); } diff --git a/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java b/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java index b3ba30a..26b4db1 100644 --- a/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java +++ b/src/de/steamwar/bungeecore/commands/ServerTeamchatCommand.java @@ -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)); } } diff --git a/src/de/steamwar/bungeecore/commands/TeamchatCommand.java b/src/de/steamwar/bungeecore/commands/TeamchatCommand.java index 41c3c91..60e57dc 100644 --- a/src/de/steamwar/bungeecore/commands/TeamchatCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamchatCommand.java @@ -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)); } } diff --git a/src/de/steamwar/bungeecore/commands/TpCommand.java b/src/de/steamwar/bungeecore/commands/TpCommand.java index ee50ea5..704a0aa 100644 --- a/src/de/steamwar/bungeecore/commands/TpCommand.java +++ b/src/de/steamwar/bungeecore/commands/TpCommand.java @@ -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; } diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index bd02b3d..7775dea 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -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 receivers, String format, String message) { + public static void sendChat(ChatSender sender, Stream 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())); }