Interface PermissionProvider
Permission plugins like LuckPerms should implement this interface and register it with the proxy to provide permission checking.
Registration
public class LuckPermsProvider implements PermissionProvider {
@Override
public PermissionFunction createFunction(PermissionSubject subject) {
if (!(subject instanceof Player player)) {
// Return a default function for non-player subjects (e.g., console)
return PermissionFunction.ALWAYS_TRUE;
}
User user = luckPerms.getUserManager().getUser(player.getUniqueId());
return permission -> {
if (user == null) return Tristate.UNDEFINED;
return Tristate.fromBoolean(user.getCachedData()
.getPermissionData().checkPermission(permission).asBoolean());
};
}
}
// Register with proxy
Numdrassl.getProxy().getPermissionManager().setProvider(new LuckPermsProvider());
Subject Types
The subject passed to createFunction(PermissionSubject) can be:
Player- a connected player- Console command source - the server console
Lifecycle
The createFunction(PermissionSubject) method is called when a subject
needs permissions set up. For players, this happens during connection. The function
may be cached and reused for the duration of the session.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptioncreateFunction(PermissionSubject subject) Creates a permission function for the given subject.default voidCalled when this provider is registered.default voidCalled when this provider is unregistered.
-
Method Details
-
createFunction
Creates a permission function for the given subject.This method is called when a subject's permissions need to be set up. The returned function will be used for all permission checks for this subject.
Implementations should handle both player and non-player subjects appropriately. Use
instanceofto distinguish between subject types:if (subject instanceof Player player) { // Player-specific logic } else { // Console or other subject types }- Parameters:
subject- the permission subject to create a function for- Returns:
- the permission function for this subject
-
onRegister
default void onRegister()Called when this provider is registered.Override this to perform initialization when the provider is installed.
-
onUnregister
default void onUnregister()Called when this provider is unregistered.Override this to perform cleanup when the provider is removed.
-