Overhauled command handling and suggestion support.
This commit is contained in:
@@ -19,23 +19,22 @@
|
||||
|
||||
package com.sk89q.worldedit.internal.command;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.util.command.parametric.PermissionsHandler;
|
||||
import com.sk89q.worldedit.util.auth.Authorizer;
|
||||
|
||||
public class CommandPermissionsHandler extends PermissionsHandler {
|
||||
|
||||
public CommandPermissionsHandler() {
|
||||
}
|
||||
/**
|
||||
* Implementation of an authorizer that uses {@link Actor#hasPermission(String)}.
|
||||
*/
|
||||
public class ActorAuthorizer implements Authorizer {
|
||||
|
||||
@Override
|
||||
protected boolean hasPermission(CommandContext context, String permission) {
|
||||
Actor sender = context.getLocals().get(Actor.class);
|
||||
public boolean testPermission(CommandLocals locals, String permission) {
|
||||
Actor sender = locals.get(Actor.class);
|
||||
if (sender == null) {
|
||||
throw new RuntimeException("Uh oh! No 'Actor' specified so that we can check permissions");
|
||||
} else {
|
||||
return sender.hasPermission(permission);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user