Package dev.polv.taleapi.event.player
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.
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.");
}
});
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiononPlayerJoin(TalePlayer player) Called when a player joins the server.
-
Field Details
-
EVENT
The event instance. Use this to register listeners and fire the event.
-
-
Method Details
-
onPlayerJoin
Called when a player joins the server.- Parameters:
player- the player who is joining- Returns:
- a future containing the event result -
EventResult.CANCELto prevent the join. UseEventResult.pass(),EventResult.cancel(), etc. for sync responses.
-