Register command permissions, integrate with the Bukkit help API
Help API support requires a fix in Bukkit to work fully Allow annotation-free registering of commands with other plugins
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.bukkit.util;
|
||||
|
||||
import com.sk89q.util.StringUtil;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import java.util.Arrays;
|
||||
@@ -29,18 +30,36 @@ import java.util.Arrays;
|
||||
public class DynamicPluginCommand extends org.bukkit.command.Command {
|
||||
|
||||
protected final CommandExecutor owner;
|
||||
protected final Object registeredWith;
|
||||
protected String[] permissions = new String[0];
|
||||
|
||||
public DynamicPluginCommand(String[] aliases, String desc, String usage, CommandExecutor owner) {
|
||||
public DynamicPluginCommand(String[] aliases, String desc, String usage, CommandExecutor owner, Object registeredWith) {
|
||||
super(aliases[0], desc, usage, Arrays.asList(aliases));
|
||||
this.owner = owner;
|
||||
this.registeredWith = registeredWith;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
return owner.onCommand(sender, this, label, args);
|
||||
}
|
||||
|
||||
|
||||
public Object getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public Object getRegisteredWith() {
|
||||
return registeredWith;
|
||||
}
|
||||
|
||||
public void setPermissions(String[] permissions) {
|
||||
this.permissions = permissions;
|
||||
if (permissions != null) {
|
||||
super.setPermission(StringUtil.joinString(permissions, ";"));
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user