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.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;
}