Interface PlayerJoinCallback

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface PlayerJoinCallback
Called when a player joins the server.

This event is cancellable and fully async. If cancelled, the player will be prevented from joining (kicked).

Handlers return a CompletableFuture of EventResult. Use EventResult.pass(), EventResult.cancel(), etc. for synchronous handlers, or return a future directly for async operations.

Example Usage


 // Synchronous handler
 PlayerJoinCallback.EVENT.register(player -> {
   player.sendMessage("Welcome to the server, " + player.getName() + "!");
   return EventResult.pass();
 });

 // Async handler - database ban check
 PlayerJoinCallback.EVENT.register(EventPriority.HIGHEST, player -> database.isPlayerBanned(player.getUUID())
     .thenApply(banned -> banned ? EventResult.CANCEL : EventResult.PASS));

 // Async handler with blocking operation
 PlayerJoinCallback.EVENT.register(player -> CompletableFuture.supplyAsync(() -> {
   boolean banned = blockingBanCheck(player.getUUID());
   return banned ? EventResult.CANCEL : EventResult.PASS;
 }, dbExecutor));
 

Firing the Event


 PlayerJoinCallback.EVENT.invoker().onPlayerJoin(player)
     .thenAccept(result -> {
       if (result.isCancelled()) {
         player.kick("You are not allowed to join.");
       }
     });