From f1f334a750e8611ccdb9f8cb8066dfcff61285d2 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 22 Apr 2022 15:44:42 +0200 Subject: [PATCH 1/5] 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())); } From 4d53e8ced92a2b491222f29f4e74cadacd5a36aa Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 22 Apr 2022 16:14:35 +0200 Subject: [PATCH 2/5] Fix chatcolor, arenacommand Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/commands/ArenaCommand.java | 5 +++-- src/de/steamwar/bungeecore/listeners/ChatListener.java | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/ArenaCommand.java b/src/de/steamwar/bungeecore/commands/ArenaCommand.java index 15241cf..339c66a 100644 --- a/src/de/steamwar/bungeecore/commands/ArenaCommand.java +++ b/src/de/steamwar/bungeecore/commands/ArenaCommand.java @@ -19,8 +19,8 @@ package de.steamwar.bungeecore.commands; -import de.steamwar.bungeecore.Arenaserver; import de.steamwar.bungeecore.Message; +import de.steamwar.bungeecore.Servertype; import de.steamwar.bungeecore.Subserver; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; @@ -40,7 +40,8 @@ public class ArenaCommand extends BasicCommand { ProxiedPlayer player = (ProxiedPlayer) sender; ServerInfo server = ProxyServer.getInstance().getServerInfo(String.join(" ", args)); - if(server == null || !(Subserver.getSubserver(server) instanceof Arenaserver)) { + Subserver subserver = Subserver.getSubserver(server); + if(server == null || subserver == null || subserver.getType() != Servertype.ARENA) { Message.send("ARENA_NOT_FOUND", player); return; } diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index 7775dea..81c4fff 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -68,6 +68,7 @@ public class ChatListener extends BasicListener { } else { e.setCancelled(true); + //TODO /arena Subserver subserver = Subserver.getSubserver(player); if(subserver instanceof Arenaserver && subserver.getServer() == player.getServer().getInfo()) { localChat(player, message); @@ -162,7 +163,7 @@ public class ChatListener extends BasicListener { sender.getTeam() == 0 ? "" : "§" + Team.get(sender.getTeam()).getTeamColor() + Team.get(sender.getTeam()).getTeamKuerzel() + " ", UserElo.getEmblem(sender), group.getColorCode(), - group.getChatPrefix().length() == 0 ? "" : group.getChatPrefix() + " ", + group.getChatPrefix().length() == 0 ? "§f" : group.getChatPrefix() + " ", group.getChatColorCode())); } From 329d80f03793cf5b09d83ea9977fb4c5f20747f0 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 22 Apr 2022 17:10:32 +0200 Subject: [PATCH 3/5] Fix Arenaserver Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/Message.java | 4 ++-- src/de/steamwar/bungeecore/commands/TpCommand.java | 2 +- src/de/steamwar/bungeecore/listeners/ChatListener.java | 3 +-- src/de/steamwar/messages/ChatSender.java | 7 ++----- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/de/steamwar/bungeecore/Message.java b/src/de/steamwar/bungeecore/Message.java index 1267847..90ee341 100644 --- a/src/de/steamwar/bungeecore/Message.java +++ b/src/de/steamwar/bungeecore/Message.java @@ -116,7 +116,7 @@ public class Message { } public static void broadcast(String message, String onHover, ClickEvent onClick, Object... params) { - ChatSender.allReceivers().forEach(player -> player.prefixless(message, new Message(onHover, params), onClick, params)); + ChatSender.allReceivers().forEach(player -> player.prefixless(message, onHover != null ? new Message(onHover, params) : null, onClick, params)); } public static void team(String message, Object... params) { @@ -124,7 +124,7 @@ public class Message { } public static void team(String message, String onHover, ClickEvent onClick, Object... params) { - ChatSender.serverteamReceivers().filter(player -> player.user().getUserGroup().isTeamGroup()).forEach(player -> player.prefixless(message, new Message(onHover, params), onClick, params)); + ChatSender.serverteamReceivers().filter(player -> player.user().getUserGroup().isTeamGroup()).forEach(player -> player.prefixless(message, onHover != null ? new Message(onHover, params) : null, onClick, params)); } private final String format; diff --git a/src/de/steamwar/bungeecore/commands/TpCommand.java b/src/de/steamwar/bungeecore/commands/TpCommand.java index 704a0aa..801ed2c 100644 --- a/src/de/steamwar/bungeecore/commands/TpCommand.java +++ b/src/de/steamwar/bungeecore/commands/TpCommand.java @@ -81,7 +81,7 @@ public class TpCommand extends BasicCommand { String serverPerm = BungeeCore.serverPermissions.get(server.getName()); Subserver subserver = Subserver.getSubserver(server); - if (subserver instanceof Arenaserver) { + if (subserver != null && subserver.getType() == Servertype.ARENA) { if (!sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) SubserverSystem.sendPlayer(subserver, player); diff --git a/src/de/steamwar/bungeecore/listeners/ChatListener.java b/src/de/steamwar/bungeecore/listeners/ChatListener.java index 81c4fff..f565677 100644 --- a/src/de/steamwar/bungeecore/listeners/ChatListener.java +++ b/src/de/steamwar/bungeecore/listeners/ChatListener.java @@ -68,9 +68,8 @@ public class ChatListener extends BasicListener { } else { e.setCancelled(true); - //TODO /arena Subserver subserver = Subserver.getSubserver(player); - if(subserver instanceof Arenaserver && subserver.getServer() == player.getServer().getInfo()) { + if(subserver != null && subserver.getType() == Servertype.ARENA && subserver.getServer() == player.getServer().getInfo()) { localChat(player, message); } else if (message.startsWith("+")) { localChat(player, message.substring(1)); diff --git a/src/de/steamwar/messages/ChatSender.java b/src/de/steamwar/messages/ChatSender.java index 3d1fb55..de80541 100644 --- a/src/de/steamwar/messages/ChatSender.java +++ b/src/de/steamwar/messages/ChatSender.java @@ -19,10 +19,7 @@ package de.steamwar.messages; -import de.steamwar.bungeecore.Arenaserver; -import de.steamwar.bungeecore.BungeeCore; -import de.steamwar.bungeecore.Message; -import de.steamwar.bungeecore.Subserver; +import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.bot.listeners.DiscordChatListener; import de.steamwar.bungeecore.sql.SteamwarUser; import net.md_5.bungee.api.ChatMessageType; @@ -59,7 +56,7 @@ public interface ChatSender { static Stream globalReceivers() { return all().filter(player -> { Subserver subserver = Subserver.getSubserver(player); - return !(subserver instanceof Arenaserver && subserver.getServer() == player.getServer().getInfo()); + return subserver == null || !(subserver.getType() == Servertype.ARENA && subserver.getServer() == player.getServer().getInfo()); }).map(ChatSender::of); } From 015a3cfa52e983908f632a92a0c822b40c370ee1 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 22 Apr 2022 17:26:28 +0200 Subject: [PATCH 4/5] Fix broeadcasts Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/Message.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/Message.java b/src/de/steamwar/bungeecore/Message.java index 90ee341..b253b1d 100644 --- a/src/de/steamwar/bungeecore/Message.java +++ b/src/de/steamwar/bungeecore/Message.java @@ -116,7 +116,7 @@ public class Message { } public static void broadcast(String message, String onHover, ClickEvent onClick, Object... params) { - ChatSender.allReceivers().forEach(player -> player.prefixless(message, onHover != null ? new Message(onHover, params) : null, onClick, params)); + ChatSender.allReceivers().forEach(player -> player.system(message, onHover != null ? new Message(onHover, params) : null, onClick, params)); } public static void team(String message, Object... params) { From 9ac5a8ef8a3fdf3f3fa8c2aced9211f77962770c Mon Sep 17 00:00:00 2001 From: Lixfel Date: Fri, 22 Apr 2022 18:47:21 +0200 Subject: [PATCH 5/5] Fix sends Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/Message.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/de/steamwar/bungeecore/Message.java b/src/de/steamwar/bungeecore/Message.java index b253b1d..1f1213f 100644 --- a/src/de/steamwar/bungeecore/Message.java +++ b/src/de/steamwar/bungeecore/Message.java @@ -108,7 +108,7 @@ public class Message { if(type == ChatMessageType.CHAT && !sender.chatShown()) return; - sender.send(prefixed, type, new Message("PLAIN_STRING", onHover), onClick, new Message(message, params)); + sender.send(prefixed, type, onHover != null ? new Message("PLAIN_STRING", onHover) : null, onClick, new Message(message, params)); } public static void broadcast(String message, Object... params) {