From 7aadaa2df37b8ab36e519d9446efb0d608780dbf Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 14 Jun 2022 09:32:43 +0200 Subject: [PATCH] Fix communication Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/BungeeCore.java | 2 ++ src/de/steamwar/bungeecore/commands/TeamCommand.java | 4 +--- src/de/steamwar/bungeecore/network/NetworkReceiver.java | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 40b8399..5cd415e 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -24,6 +24,7 @@ import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; import de.steamwar.bungeecore.commands.*; import de.steamwar.bungeecore.listeners.*; import de.steamwar.bungeecore.listeners.mods.*; +import de.steamwar.bungeecore.network.BungeeNetworkHandler; import de.steamwar.bungeecore.network.NetworkReceiver; import de.steamwar.bungeecore.sql.*; import net.md_5.bungee.api.ChatMessageType; @@ -157,6 +158,7 @@ public class BungeeCore extends Plugin { new EventStarter(); new SessionManager(); new NetworkReceiver(); + BungeeNetworkHandler.register(); new TablistManager(); new SettingsChangedListener(); diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index f5aab33..a6d814c 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -25,9 +25,7 @@ import de.steamwar.bungeecore.inventory.SWItem; import de.steamwar.bungeecore.inventory.SWListInv; import de.steamwar.bungeecore.sql.*; import de.steamwar.messages.ChatSender; -import io.netty.channel.ConnectTimeoutException; import net.md_5.bungee.BungeeCord; -import net.md_5.bungee.UserConnection; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.ProxyServer; @@ -660,7 +658,7 @@ public class TeamCommand extends BasicCommand { Message.send("TEAM_SERVER_SET", player); } - private static boolean isLocalhost(InetAddress addr) { + public static boolean isLocalhost(InetAddress addr) { // Check if the address is a valid special local or loop back if (addr.isAnyLocalAddress() || addr.isLoopbackAddress()) return true; diff --git a/src/de/steamwar/bungeecore/network/NetworkReceiver.java b/src/de/steamwar/bungeecore/network/NetworkReceiver.java index 628270e..e87c7f0 100644 --- a/src/de/steamwar/bungeecore/network/NetworkReceiver.java +++ b/src/de/steamwar/bungeecore/network/NetworkReceiver.java @@ -20,6 +20,7 @@ package de.steamwar.bungeecore.network; import de.steamwar.bungeecore.BungeeCore; +import de.steamwar.bungeecore.commands.TeamCommand; import de.steamwar.bungeecore.listeners.BasicListener; import de.steamwar.network.packets.NetworkPacket; import net.md_5.bungee.api.config.ServerInfo; @@ -36,18 +37,17 @@ import java.util.logging.Level; public class NetworkReceiver extends BasicListener { private static final List blockedTags = Arrays.asList("bungeecord:main", "BungeeCord", "sw:bridge"); - private static final List allowedAddresses = Arrays.asList("localhost", "127.0.0.1", "0.0.0.0"); public static ServerInfo sender; @EventHandler(priority = EventPriority.HIGHEST) public synchronized void onPluginMessage(PluginMessageEvent event) { - if (blockedTags.contains(event.getTag()) && !allowedAddresses.contains(((InetSocketAddress) event.getSender().getSocketAddress()).getHostString())) { + if (blockedTags.contains(event.getTag()) && !TeamCommand.isLocalhost(((InetSocketAddress) event.getSender().getSocketAddress()).getAddress())) { 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().equals("sw:bridge")) return; event.setCancelled(true);