update BaseCommand...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-09-22 20:21:55 +08:00
parent 8c17dd8908
commit 39f72995a2
11 changed files with 21 additions and 35 deletions

View File

@ -20,17 +20,18 @@ public abstract class BaseCommand {
private String name; private String name;
private String permission; private String permission;
private String[] aliases; private String[] aliases;
private String description = ""; private String description;
private int minimumArguments = 0; private int minimumArguments = 0;
private String possibleArguments = ""; private String possibleArguments = "";
private boolean onlyPlayerExecutable = false; private boolean onlyPlayerExecutable = false;
public BaseCommand(String name) { public BaseCommand(String name, String description) {
this(name, new String[0]); this(name, description, new String[0]);
} }
public BaseCommand(String name, String... aliases) { public BaseCommand(String name, String description, String... aliases) {
this.name = name; this.name = name;
this.description = description;
this.aliases = aliases; this.aliases = aliases;
} }
@ -48,6 +49,11 @@ public abstract class BaseCommand {
*/ */
public abstract void execute(CommandSender sender, String label, String[] args) throws CommandException; public abstract void execute(CommandSender sender, String label, String[] args) throws CommandException;
/**
* 获得当前命令的别名
*
* @return 当前命令的别名
*/
public List<String> getCommandList() { public List<String> getCommandList() {
List<String> cmds = new ArrayList<String>(); List<String> cmds = new ArrayList<String>();
cmds.add(name); cmds.add(name);
@ -139,16 +145,6 @@ public abstract class BaseCommand {
return false; return false;
} }
/**
* 设置命令的描述信息
*
* @param description
* - 命令描述
*/
public void setDescription(String description) {
this.description = description;
}
/** /**
* 设置命令的最小参数个数 * 设置命令的最小参数个数
* *

View File

@ -23,9 +23,8 @@ public class CommandDelete extends BaseCommand {
* @param name * @param name
*/ */
public CommandDelete(Yum main) { public CommandDelete(Yum main) {
super("delete"); super("delete", "删除插件");
this.main = main; this.main = main;
setDescription("删除插件");
setMinimumArguments(1); setMinimumArguments(1);
setPossibleArguments("<插件名称>"); setPossibleArguments("<插件名称>");
} }

View File

@ -25,9 +25,8 @@ public class CommandInfo extends BaseCommand {
* @param name * @param name
*/ */
public CommandInfo(Yum main) { public CommandInfo(Yum main) {
super("info"); super("info", "查看插件详情");
this.main = main; this.main = main;
setDescription("查看插件详情");
setPossibleArguments("<插件名称>"); setPossibleArguments("<插件名称>");
} }

View File

@ -23,9 +23,8 @@ public class CommandInstall extends BaseCommand {
* @param name * @param name
*/ */
public CommandInstall(Yum main) { public CommandInstall(Yum main) {
super("install"); super("install", "安装插件");
this.main = main; this.main = main;
setDescription("安装插件");
setMinimumArguments(1); setMinimumArguments(1);
setPossibleArguments("<插件名称>"); setPossibleArguments("<插件名称>");
} }

View File

@ -23,9 +23,8 @@ public class CommandList extends BaseCommand {
* @param name * @param name
*/ */
public CommandList(Yum main) { public CommandList(Yum main) {
super("list"); super("list", "列出已安装插件列表");
this.main = main; this.main = main;
setDescription("列出已安装插件列表");
} }
@Override @Override

View File

@ -23,9 +23,8 @@ public class CommandLoad extends BaseCommand {
* @param name * @param name
*/ */
public CommandLoad(Yum main) { public CommandLoad(Yum main) {
super("load"); super("load", "载入插件");
this.main = main; this.main = main;
setDescription("载入插件");
setMinimumArguments(1); setMinimumArguments(1);
setPossibleArguments("<插件名称>"); setPossibleArguments("<插件名称>");
} }

View File

@ -23,9 +23,8 @@ public class CommandReload extends BaseCommand {
* @param name * @param name
*/ */
public CommandReload(Yum main) { public CommandReload(Yum main) {
super("reload"); super("reload", "重载插件");
this.main = main; this.main = main;
setDescription("重载插件");
setMinimumArguments(1); setMinimumArguments(1);
setPossibleArguments("<插件名称|all|*>"); setPossibleArguments("<插件名称|all|*>");
} }

View File

@ -22,9 +22,8 @@ public class CommandRepo extends BaseCommand {
* @param name * @param name
*/ */
public CommandRepo(Yum main) { public CommandRepo(Yum main) {
super("repo"); super("repo", "插件源命令");
this.main = main; this.main = main;
setDescription("插件源命令");
setMinimumArguments(1); setMinimumArguments(1);
setPossibleArguments("<add|del|clean|list> <仓库名称>"); setPossibleArguments("<add|del|clean|list> <仓库名称>");
} }

View File

@ -23,9 +23,8 @@ public class CommandUnload extends BaseCommand {
* @param name * @param name
*/ */
public CommandUnload(Yum main) { public CommandUnload(Yum main) {
super("unload"); super("unload", "卸载插件");
this.main = main; this.main = main;
setDescription("卸载插件");
setMinimumArguments(1); setMinimumArguments(1);
setPossibleArguments("<插件名称>"); setPossibleArguments("<插件名称>");
} }

View File

@ -21,9 +21,8 @@ public class CommandUpdate extends BaseCommand {
* @param name * @param name
*/ */
public CommandUpdate(Yum main) { public CommandUpdate(Yum main) {
super("update"); super("update", "更新插件");
this.main = main; this.main = main;
setDescription("更新插件");
setMinimumArguments(1); setMinimumArguments(1);
setPossibleArguments("<插件名称> [插件版本]"); setPossibleArguments("<插件名称> [插件版本]");
} }

View File

@ -21,9 +21,8 @@ public class CommandUpgrade extends BaseCommand {
* @param name * @param name
*/ */
public CommandUpgrade(Yum main) { public CommandUpgrade(Yum main) {
super("upgrade"); super("upgrade", "升级插件");
this.main = main; this.main = main;
setDescription("升级插件");
setMinimumArguments(1); setMinimumArguments(1);
setPossibleArguments("<插件名称>"); setPossibleArguments("<插件名称>");
} }