SteamWar/BungeeCore
Archiviert
13
2

Speed BrandListener up

Dieser Commit ist enthalten in:
yoyosource 2022-04-27 09:58:15 +02:00
Ursprung f30b779347
Commit 6e158b38b8

Datei anzeigen

@ -28,15 +28,30 @@ import net.md_5.bungee.api.event.PluginMessageEvent;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.DefinedPacket;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
public class BrandListener extends BasicListener { 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 @EventHandler
public void onServerSwitch(PluginMessageEvent event) { public void onServerSwitch(PluginMessageEvent event) {
if(!event.getTag().equals("minecraft:brand") && !event.getTag().equals("MC|Brand")) { if(!event.getTag().equals("minecraft:brand") && !event.getTag().equals("MC|Brand")) {
return; return;
} }
if(event.getReceiver().getAddress().getHostName().contains("localhost")) { if (isLocalHost(event.getReceiver().getAddress().getAddress())) {
return; return;
} }