geforkt von SteamWar/BungeeCore
Fix Remote Plugin Messages
Dieser Commit ist enthalten in:
Ursprung
446b4ad519
Commit
a97a6a78e2
@ -1,5 +1,6 @@
|
|||||||
package de.steamwar.bungeecore.network;
|
package de.steamwar.bungeecore.network;
|
||||||
|
|
||||||
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.listeners.BasicListener;
|
import de.steamwar.bungeecore.listeners.BasicListener;
|
||||||
import de.steamwar.network.packets.NetworkPacket;
|
import de.steamwar.network.packets.NetworkPacket;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
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.api.event.PluginMessageEvent;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
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 {
|
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;
|
public static ServerInfo sender;
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPluginMessage(PluginMessageEvent event) {
|
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"))
|
if(!event.getTag().equalsIgnoreCase("sw:bridge"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren