SteamWar/BungeeCore
Archiviert
13
2

Merge pull request 'Fix 7/ replacer' (#423) from fix7replacer into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #423
Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Lixfel 2022-08-23 17:31:17 +02:00
Commit d232d18fda

Datei anzeigen

@ -56,31 +56,43 @@ public class ChatListener extends BasicListener {
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
String message = e.getMessage();
e.setCancelled(true);
if (message.contains("jndi:ldap")) {
e.setCancelled(true);
SteamwarUser.get(player).punishPerma(Punishment.PunishmentType.Ban, "Versuchte Exploit-Ausnutzung", 0);
return;
}
message = sanitize7(message);
if (isCommand(player, message))
return;
if (message.startsWith("/")) {
if(filteredCommand((CommandSender) e.getSender(), message))
e.setCancelled(true);
Subserver subserver = Subserver.getSubserver(player);
if(subserver != null && subserver.getType() == Servertype.ARENA && subserver.getServer() == player.getServer().getInfo()) {
localChat(player, message);
} else if (message.startsWith("+")) {
localChat(player, message.substring(1));
} else {
e.setCancelled(true);
Subserver subserver = Subserver.getSubserver(player);
if(subserver != null && subserver.getType() == Servertype.ARENA && subserver.getServer() == player.getServer().getInfo()) {
localChat(player, message);
} else if (message.startsWith("+")) {
localChat(player, message.substring(1));
} else {
sendChat(ChatSender.of(player), ChatSender.globalReceivers(), "CHAT_GLOBAL", null, message);
}
sendChat(ChatSender.of(player), ChatSender.globalReceivers(), "CHAT_GLOBAL", null, message);
}
}
private static boolean isCommand(ProxiedPlayer player, String message) {
String command = message.substring(1);
boolean isCommand = message.startsWith("/") || (message.startsWith("7") && command.split(" ", 2)[0].matches("[7/]?[A-Za-z]+"));
if(isCommand && !ProxyServer.getInstance().getPluginManager().dispatchCommand(player, command)) {
if(command.startsWith("7"))
command = "/" + command.substring(1);
message = "/" + command;
if(filteredCommand(player, message))
return true;
Chat19.chat(player, message);
}
return isCommand;
}
public static void sendChat(ChatSender sender, Stream<ChatSender> receivers, String format, ChatSender msgReceiver, String message) {
SteamwarUser user = sender.user();
final String coloredMessage = (user.getUserGroup() != UserGroup.Member || coloredTeams.contains(user.getTeam())) ? ChatColor.translateAlternateColorCodes('&', message) : message;
@ -114,8 +126,6 @@ public class ChatListener extends BasicListener {
return;
}
message = sanitize7(message);
if(ChatListener.filteredCommand(player, message))
return;
@ -167,17 +177,6 @@ public class ChatListener extends BasicListener {
group.getChatColorCode()));
}
private static String sanitize7(String message) {
String begin = message.split(" ", 2)[0];
if(begin.startsWith("7") && begin.substring(1).matches("[A-Za-z]+")){
message = "/" + message.substring(1);
}else if((begin.startsWith("77") || begin.startsWith("7/") || begin.startsWith("/7")) && begin.substring(2).matches("[A-Za-z]+")){
message = "//" + message.substring(2);
}
return message;
}
private static boolean filteredCommand(CommandSender sender, String message) {
String command = message.split(" ", 2)[0];
if(command.startsWith("/") && command.contains(":")) {