Package dev.polv.taleapi.event.player
Interface PermissionCheckCallback
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Called after a permission provider calculates a result but before the game receives it.
This event allows plugins to temporarily override permissions without modifying the underlying permission data. Common use cases include:
- Denying all commands during a minigame match
- Granting temporary permissions during an event
- Implementing custom permission logic based on game state
Example Usage
// Deny all teleport commands during a match
PermissionCheckCallback.EVENT.register((player, key, context, result) -> {
if (matchManager.isInMatch(player) && key.startsWith("cmd.teleport")) {
return CheckResult.deny(); // Override to DENY
}
return CheckResult.unmodified(); // Keep original result
});
// Grant temporary fly permission during an event
PermissionCheckCallback.EVENT.register((player, key, context, result) -> {
if (eventManager.hasTemporaryFlight(player) && key.equals("ability.fly")) {
return CheckResult.allow();
}
return CheckResult.unmodified();
});
Priority
Listeners with higher EventPriority run first
and can override the result for subsequent listeners. Use HIGHEST priority
for security-critical overrides.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classRepresents the result of a permission check callback. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiononPermissionCheck(TalePlayer player, String key, ContextSet context, PermissionResult result) Called when a permission is being checked.
-
Field Details
-
EVENT
The event instance. Use this to register listeners.
-
-
Method Details
-
onPermissionCheck
PermissionCheckCallback.CheckResult onPermissionCheck(TalePlayer player, String key, ContextSet context, PermissionResult result) Called when a permission is being checked.- Parameters:
player- the player whose permission is being checkedkey- the permission key being queriedcontext- the context of the checkresult- the current permission result (from provider or previous listeners)- Returns:
- a CheckResult indicating whether to modify the result
-