From 39f72995a2e3a3dd4a96f8fba30d896a1bb4b18d Mon Sep 17 00:00:00 2001 From: 502647092 Date: Tue, 22 Sep 2015 20:21:55 +0800 Subject: [PATCH] update BaseCommand... Signed-off-by: 502647092 --- .../citycraft/Yum/commands/BaseCommand.java | 26 ++++++++----------- .../citycraft/Yum/commands/CommandDelete.java | 3 +-- .../citycraft/Yum/commands/CommandInfo.java | 3 +-- .../Yum/commands/CommandInstall.java | 3 +-- .../citycraft/Yum/commands/CommandList.java | 3 +-- .../citycraft/Yum/commands/CommandLoad.java | 3 +-- .../citycraft/Yum/commands/CommandReload.java | 3 +-- .../citycraft/Yum/commands/CommandRepo.java | 3 +-- .../citycraft/Yum/commands/CommandUnload.java | 3 +-- .../citycraft/Yum/commands/CommandUpdate.java | 3 +-- .../Yum/commands/CommandUpgrade.java | 3 +-- 11 files changed, 21 insertions(+), 35 deletions(-) diff --git a/src/main/java/cn/citycraft/Yum/commands/BaseCommand.java b/src/main/java/cn/citycraft/Yum/commands/BaseCommand.java index ea36e74..72c452e 100644 --- a/src/main/java/cn/citycraft/Yum/commands/BaseCommand.java +++ b/src/main/java/cn/citycraft/Yum/commands/BaseCommand.java @@ -20,17 +20,18 @@ public abstract class BaseCommand { private String name; private String permission; private String[] aliases; - private String description = "无"; + private String description; private int minimumArguments = 0; private String possibleArguments = ""; private boolean onlyPlayerExecutable = false; - public BaseCommand(String name) { - this(name, new String[0]); + public BaseCommand(String name, String description) { + this(name, description, new String[0]); } - public BaseCommand(String name, String... aliases) { + public BaseCommand(String name, String description, String... aliases) { this.name = name; + this.description = description; this.aliases = aliases; } @@ -48,6 +49,11 @@ public abstract class BaseCommand { */ public abstract void execute(CommandSender sender, String label, String[] args) throws CommandException; + /** + * 获得当前命令的别名 + * + * @return 当前命令的别名 + */ public List getCommandList() { List cmds = new ArrayList(); cmds.add(name); @@ -139,16 +145,6 @@ public abstract class BaseCommand { return false; } - /** - * 设置命令的描述信息 - * - * @param description - * - 命令描述 - */ - public void setDescription(String description) { - this.description = description; - } - /** * 设置命令的最小参数个数 * @@ -181,7 +177,7 @@ public abstract class BaseCommand { /** * 设置可能的命令参数 - * + * * @param possibleArguments * - 可能的命令参数 */ diff --git a/src/main/java/cn/citycraft/Yum/commands/CommandDelete.java b/src/main/java/cn/citycraft/Yum/commands/CommandDelete.java index 389866b..26382c9 100644 --- a/src/main/java/cn/citycraft/Yum/commands/CommandDelete.java +++ b/src/main/java/cn/citycraft/Yum/commands/CommandDelete.java @@ -23,9 +23,8 @@ public class CommandDelete extends BaseCommand { * @param name */ public CommandDelete(Yum main) { - super("delete"); + super("delete", "删除插件"); this.main = main; - setDescription("删除插件"); setMinimumArguments(1); setPossibleArguments("<插件名称>"); } diff --git a/src/main/java/cn/citycraft/Yum/commands/CommandInfo.java b/src/main/java/cn/citycraft/Yum/commands/CommandInfo.java index 41c0871..22b3681 100644 --- a/src/main/java/cn/citycraft/Yum/commands/CommandInfo.java +++ b/src/main/java/cn/citycraft/Yum/commands/CommandInfo.java @@ -25,9 +25,8 @@ public class CommandInfo extends BaseCommand { * @param name */ public CommandInfo(Yum main) { - super("info"); + super("info", "查看插件详情"); this.main = main; - setDescription("查看插件详情"); setPossibleArguments("<插件名称>"); } diff --git a/src/main/java/cn/citycraft/Yum/commands/CommandInstall.java b/src/main/java/cn/citycraft/Yum/commands/CommandInstall.java index c74f6bc..bcc5b08 100644 --- a/src/main/java/cn/citycraft/Yum/commands/CommandInstall.java +++ b/src/main/java/cn/citycraft/Yum/commands/CommandInstall.java @@ -23,9 +23,8 @@ public class CommandInstall extends BaseCommand { * @param name */ public CommandInstall(Yum main) { - super("install"); + super("install", "安装插件"); this.main = main; - setDescription("安装插件"); setMinimumArguments(1); setPossibleArguments("<插件名称>"); } diff --git a/src/main/java/cn/citycraft/Yum/commands/CommandList.java b/src/main/java/cn/citycraft/Yum/commands/CommandList.java index 367bb59..ee14010 100644 --- a/src/main/java/cn/citycraft/Yum/commands/CommandList.java +++ b/src/main/java/cn/citycraft/Yum/commands/CommandList.java @@ -23,9 +23,8 @@ public class CommandList extends BaseCommand { * @param name */ public CommandList(Yum main) { - super("list"); + super("list", "列出已安装插件列表"); this.main = main; - setDescription("列出已安装插件列表"); } @Override diff --git a/src/main/java/cn/citycraft/Yum/commands/CommandLoad.java b/src/main/java/cn/citycraft/Yum/commands/CommandLoad.java index f4c3b2a..a60c2ae 100644 --- a/src/main/java/cn/citycraft/Yum/commands/CommandLoad.java +++ b/src/main/java/cn/citycraft/Yum/commands/CommandLoad.java @@ -23,9 +23,8 @@ public class CommandLoad extends BaseCommand { * @param name */ public CommandLoad(Yum main) { - super("load"); + super("load", "载入插件"); this.main = main; - setDescription("载入插件"); setMinimumArguments(1); setPossibleArguments("<插件名称>"); } diff --git a/src/main/java/cn/citycraft/Yum/commands/CommandReload.java b/src/main/java/cn/citycraft/Yum/commands/CommandReload.java index 3e8dae3..4b3e474 100644 --- a/src/main/java/cn/citycraft/Yum/commands/CommandReload.java +++ b/src/main/java/cn/citycraft/Yum/commands/CommandReload.java @@ -23,9 +23,8 @@ public class CommandReload extends BaseCommand { * @param name */ public CommandReload(Yum main) { - super("reload"); + super("reload", "重载插件"); this.main = main; - setDescription("重载插件"); setMinimumArguments(1); setPossibleArguments("<插件名称|all|*>"); } diff --git a/src/main/java/cn/citycraft/Yum/commands/CommandRepo.java b/src/main/java/cn/citycraft/Yum/commands/CommandRepo.java index 9fd359b..50283fd 100644 --- a/src/main/java/cn/citycraft/Yum/commands/CommandRepo.java +++ b/src/main/java/cn/citycraft/Yum/commands/CommandRepo.java @@ -22,9 +22,8 @@ public class CommandRepo extends BaseCommand { * @param name */ public CommandRepo(Yum main) { - super("repo"); + super("repo", "插件源命令"); this.main = main; - setDescription("插件源命令"); setMinimumArguments(1); setPossibleArguments(" <仓库名称>"); } diff --git a/src/main/java/cn/citycraft/Yum/commands/CommandUnload.java b/src/main/java/cn/citycraft/Yum/commands/CommandUnload.java index fcf4eed..5fef251 100644 --- a/src/main/java/cn/citycraft/Yum/commands/CommandUnload.java +++ b/src/main/java/cn/citycraft/Yum/commands/CommandUnload.java @@ -23,9 +23,8 @@ public class CommandUnload extends BaseCommand { * @param name */ public CommandUnload(Yum main) { - super("unload"); + super("unload", "卸载插件"); this.main = main; - setDescription("卸载插件"); setMinimumArguments(1); setPossibleArguments("<插件名称>"); } diff --git a/src/main/java/cn/citycraft/Yum/commands/CommandUpdate.java b/src/main/java/cn/citycraft/Yum/commands/CommandUpdate.java index 66b6755..058b583 100644 --- a/src/main/java/cn/citycraft/Yum/commands/CommandUpdate.java +++ b/src/main/java/cn/citycraft/Yum/commands/CommandUpdate.java @@ -21,9 +21,8 @@ public class CommandUpdate extends BaseCommand { * @param name */ public CommandUpdate(Yum main) { - super("update"); + super("update", "更新插件"); this.main = main; - setDescription("更新插件"); setMinimumArguments(1); setPossibleArguments("<插件名称> [插件版本]"); } diff --git a/src/main/java/cn/citycraft/Yum/commands/CommandUpgrade.java b/src/main/java/cn/citycraft/Yum/commands/CommandUpgrade.java index 9f118aa..ae3bd83 100644 --- a/src/main/java/cn/citycraft/Yum/commands/CommandUpgrade.java +++ b/src/main/java/cn/citycraft/Yum/commands/CommandUpgrade.java @@ -21,9 +21,8 @@ public class CommandUpgrade extends BaseCommand { * @param name */ public CommandUpgrade(Yum main) { - super("upgrade"); + super("upgrade", "升级插件"); this.main = main; - setDescription("升级插件"); setMinimumArguments(1); setPossibleArguments("<插件名称>"); }