Class AsyncLoginEvent

java.lang.Object
me.internalizable.numdrassl.api.event.connection.AsyncLoginEvent
All Implemented Interfaces:
ResultedEvent<AsyncLoginEvent.AsyncLoginResult>

public class AsyncLoginEvent extends Object implements ResultedEvent<AsyncLoginEvent.AsyncLoginResult>
Event fired during the authentication phase, specifically designed for asynchronous operations.

This event is triggered before the player is fully admitted to the server (before LoginEvent). It provides a mechanism for plugins to load blocking data (e.g., SQL databases, Redis, Web APIs) without freezing the main proxy thread.

Example Usage

@Subscribe
public void onAsyncLogin(AsyncLoginEvent event) {
     // 1. Create a future running on a separate thread (IO)
     CompletableFuture<Void> dbTask = CompletableFuture.runAsync(() -> {
         User user = database.load(event.getPlayer().getUniqueId());

         if (user.isBanned()) {
             event.setResult(AsyncLoginEvent.AsyncLoginResult.denied("You are banned"));
         }
     });

     // 2. Register the task so the proxy waits for completion
     event.registerTask(dbTask);
}