add tip color and fix command args...

Signed-off-by: j502647092 <jtb1@163.com>
This commit is contained in:
j502647092 2015-09-07 00:01:15 +08:00
parent 3140f532dc
commit ce1dab38cc
2 changed files with 22 additions and 22 deletions

View File

@ -25,30 +25,15 @@ import cn.citycraft.Yum.manager.YumManager;
* @author 蒋天蓓 2015年8月22日上午8:29:44 * @author 蒋天蓓 2015年8月22日上午8:29:44
*/ */
public class CommandHandler implements CommandExecutor, TabCompleter { public class CommandHandler implements CommandExecutor, TabCompleter {
/**
* 转移数组
*
* @param args
* - 原数组
* @param start
* - 数组开始位置
* @return 转移后的数组字符串
*/
public static String[] moveStrings(String[] args, int start) {
String[] ret = new String[args.length - start];
System.arraycopy(args, start, ret, 0, ret.length);
return ret;
}
/** /**
* 已注册命令列表(包括别名) * 已注册命令列表(包括别名)
*/ */
List<String> RegisterCommandList = new ArrayList<String>();; List<String> RegisterCommandList = new ArrayList<String>();
/** /**
* 命令监听类列表 * 命令监听类列表
*/ */
private List<BaseCommand> commandlist = new ArrayList<BaseCommand>(); private List<BaseCommand> commandlist = new ArrayList<BaseCommand>();;
/** /**
* 插件主类 * 插件主类
*/ */
@ -76,6 +61,21 @@ public class CommandHandler implements CommandExecutor, TabCompleter {
RegisterCommandList = getRegisterCommands(); RegisterCommandList = getRegisterCommands();
} }
/**
* 转移数组
*
* @param args
* - 原数组
* @param start
* - 数组开始位置
* @return 转移后的数组字符串
*/
public static String[] moveStrings(String[] args, int start) {
String[] ret = new String[args.length - start];
System.arraycopy(args, start, ret, 0, ret.length);
return ret;
}
/** /**
* 获得已注册的命令列表 * 获得已注册的命令列表
* *
@ -97,11 +97,11 @@ public class CommandHandler implements CommandExecutor, TabCompleter {
for (BaseCommand command : commandlist) for (BaseCommand command : commandlist)
if (command.isValidTrigger(subcmd)) { if (command.isValidTrigger(subcmd)) {
if (!command.hasPermission(sender)) { if (!command.hasPermission(sender)) {
sender.sendMessage("你没有此命令的权限!"); sender.sendMessage("§c你没有此命令的权限!");
return true; return true;
} }
if (command.isOnlyPlayerExecutable() && !(sender instanceof Player)) { if (command.isOnlyPlayerExecutable() && !(sender instanceof Player)) {
sender.sendMessage("控制台无法使用此命令!"); sender.sendMessage("§c控制台无法使用此命令!");
return true; return true;
} }
if (subargs.length >= command.getMinimumArguments()) if (subargs.length >= command.getMinimumArguments())
@ -112,7 +112,7 @@ public class CommandHandler implements CommandExecutor, TabCompleter {
sender.sendMessage(e.getMessage()); sender.sendMessage(e.getMessage());
} }
else else
sender.sendMessage("错误的参数 /yum " + command.getName() + command.getPossibleArguments()); sender.sendMessage("§c错误的参数 §e使用方法 /yum " + command.getName() + command.getPossibleArguments());
} }
return false; return false;
} }

View File

@ -43,7 +43,7 @@ public class CommandUpgrade extends BaseCommand {
@Override @Override
public int getMinimumArguments() { public int getMinimumArguments() {
return 1; return 0;
} }
@Override @Override