Files
FastAsyncWorldEdit/src/main/java/com/sk89q/bukkit/util/DynamicPluginCommand.java
zml2008 4328be282c 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
2012-03-09 23:16:50 -08:00

66 lines
2.0 KiB
Java

// $Id$
/*
* WorldEdit
* Copyright (C) 2011 sk89q <http://www.sk89q.com> and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.bukkit.util;
import com.sk89q.util.StringUtil;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import java.util.Arrays;
/**
* @author zml2008
*/
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, 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;
}
}