Archiviert
1
0

Fix Remote Plugin Messages

Dieser Commit ist enthalten in:
Chaoscaot 2022-06-11 08:55:51 +02:00
Ursprung 446b4ad519
Commit a97a6a78e2

Datei anzeigen

@ -1,5 +1,6 @@
package de.steamwar.bungeecore.network;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.listeners.BasicListener;
import de.steamwar.network.packets.NetworkPacket;
import net.md_5.bungee.api.config.ServerInfo;
@ -7,12 +8,25 @@ import net.md_5.bungee.api.connection.Server;
import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.event.EventHandler;
import java.net.InetSocketAddress;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
public class NetworkReceiver extends BasicListener {
private static final List<String> blockedTags = Arrays.asList("bungeecord:main", "BungeeCord", "sw:bridge");
private static final List<String> allowedAddresses = Arrays.asList("localhost", "127.0.0.1", "0.0.0.0");
public static ServerInfo sender;
@EventHandler
public void onPluginMessage(PluginMessageEvent event) {
if (blockedTags.contains(event.getTag()) && !allowedAddresses.contains(((InetSocketAddress) event.getSender().getSocketAddress()).getHostString())) {
BungeeCore.log(Level.SEVERE, ((InetSocketAddress) event.getSender().getSocketAddress()).getHostString() + " tried to send a plugin message with tag " + event.getTag());
event.setCancelled(true);
return;
}
if(!event.getTag().equalsIgnoreCase("sw:bridge"))
return;