fix: 修复之前错误的检测逻辑

merge/1/MERGE
502647092 2016-10-24 00:34:45 +08:00
parent 17c75d923e
commit 551022cf26
1 changed files with 5 additions and 2 deletions

View File

@ -272,14 +272,17 @@ public class CommandManager implements TabExecutor {
if (ci != null) {
Class[] params = method.getParameterTypes();
Log.d("命令 %s 参数类型: %s", ci.getName(), Arrays.toString(params));
if (params.length > 0 && params[0].isInstance(CommandSender.class)) {
if (method.getReturnType() == boolean.class) {
try {
Class<? extends CommandSender> sender = params[0];
// 用于消除unuse警告
if (!sender.getName().isEmpty() && method.getReturnType() == boolean.class) {
defCmd = ci;
} else {
cmds.add(ci);
cmdCache.put(ci.getName(), ci);
}
return true;
} catch (ArrayIndexOutOfBoundsException | ClassCastException ignored) {
}
Log.warning(String.format(argumentTypeError, method.getName(), clazz.getClass().getName()));
}