geforkt von SteamWar/BungeeCore
Speed BrandListener up
Dieser Commit ist enthalten in:
Ursprung
f30b779347
Commit
6e158b38b8
@ -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;
|
||||
}
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren