-
-
Notifications
You must be signed in to change notification settings - Fork 20
Authorizers
マルウェア edited this page Aug 8, 2015
·
2 revisions
An authorizer checks whether or not an actor has permission to call a certain command.
To register an authorizer, you first need to construct a ParametricBuilder
. The setAuthorizer()
method simply takes one parameter: your authorizer implementation.
builder.setAuthorizer(new ActorAuthorizer());
The Authorizer
interface only requires you to implement one method; the testPermission()
method. The method has two parameters: the namespace of the command and the permission.
A simple authorizer for e.g. Bukkit might look like this:
public class BukkitAuthorizer implements Authorizer {
@Override
public boolean testPermission(Namespace namespace, String perm) {
return namespace.get(CommandSender.class).hasPermission(perm);
}
}
Note: Remember to put your actor in the namespace when calling your command.