diff --git a/src/de/steamwar/bungeecore/listeners/BrandListener.java b/src/de/steamwar/bungeecore/listeners/BrandListener.java index c26baa7..fae5fb3 100644 --- a/src/de/steamwar/bungeecore/listeners/BrandListener.java +++ b/src/de/steamwar/bungeecore/listeners/BrandListener.java @@ -28,15 +28,30 @@ import net.md_5.bungee.api.event.PluginMessageEvent; import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.protocol.DefinedPacket; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; + public class BrandListener extends BasicListener { + private static boolean isLocalHost(InetAddress addr) { + if (addr.isAnyLocalAddress() || addr.isLoopbackAddress()) { + return true; + } + try { + return NetworkInterface.getByInetAddress(addr) != null; + } catch (SocketException e) { + return false; + } + } + @EventHandler public void onServerSwitch(PluginMessageEvent event) { if(!event.getTag().equals("minecraft:brand") && !event.getTag().equals("MC|Brand")) { return; } - if(event.getReceiver().getAddress().getHostName().contains("localhost")) { + if (isLocalHost(event.getReceiver().getAddress().getAddress())) { return; }