Search in sources :

Example 1 with AsyncPremiumCheck

use of com.github.games647.fastlogin.velocity.task.AsyncPremiumCheck in project FastLogin by games647.

the class ConnectListener method onPreLogin.

@EventHandler
public void onPreLogin(PreLoginEvent preLoginEvent) {
    PendingConnection connection = preLoginEvent.getConnection();
    if (preLoginEvent.isCancelled()) {
        return;
    }
    if (!rateLimiter.tryAcquire()) {
        plugin.getLog().warn("Simple Anti-Bot join limit - Ignoring {}", connection);
        return;
    }
    String username = connection.getName();
    plugin.getLog().info("Incoming login request for {} from {}", username, connection.getSocketAddress());
    preLoginEvent.registerIntent(plugin);
    Runnable asyncPremiumCheck = new AsyncPremiumCheck(plugin, preLoginEvent, connection, username);
    plugin.getScheduler().runAsync(asyncPremiumCheck);
}
Also used : PendingConnection(net.md_5.bungee.api.connection.PendingConnection) AsyncPremiumCheck(com.github.games647.fastlogin.bungee.task.AsyncPremiumCheck) EventHandler(net.md_5.bungee.event.EventHandler)

Example 2 with AsyncPremiumCheck

use of com.github.games647.fastlogin.velocity.task.AsyncPremiumCheck in project FastLogin by games647.

the class ConnectListener method onPreLogin.

@Subscribe
public void onPreLogin(PreLoginEvent preLoginEvent, Continuation continuation) {
    if (!preLoginEvent.getResult().isAllowed()) {
        return;
    }
    InboundConnection connection = preLoginEvent.getConnection();
    if (!rateLimiter.tryAcquire()) {
        plugin.getLog().warn("Simple Anti-Bot join limit - Ignoring {}", connection);
        return;
    }
    String username = preLoginEvent.getUsername();
    plugin.getLog().info("Incoming login request for {} from {}", username, connection.getRemoteAddress());
    Runnable asyncPremiumCheck = new AsyncPremiumCheck(plugin, connection, username, continuation, preLoginEvent);
    plugin.getScheduler().runAsync(asyncPremiumCheck);
}
Also used : InboundConnection(com.velocitypowered.api.proxy.InboundConnection) AsyncPremiumCheck(com.github.games647.fastlogin.velocity.task.AsyncPremiumCheck) Subscribe(com.velocitypowered.api.event.Subscribe)

Aggregations

AsyncPremiumCheck (com.github.games647.fastlogin.bungee.task.AsyncPremiumCheck)1 AsyncPremiumCheck (com.github.games647.fastlogin.velocity.task.AsyncPremiumCheck)1 Subscribe (com.velocitypowered.api.event.Subscribe)1 InboundConnection (com.velocitypowered.api.proxy.InboundConnection)1 PendingConnection (net.md_5.bungee.api.connection.PendingConnection)1 EventHandler (net.md_5.bungee.event.EventHandler)1