1
0
mirror of https://e.coding.net/circlecloud/YumCore.git synced 2024-11-24 02:08:48 +00:00

feat: 修复命令参数长度检测

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-07-25 16:55:06 +08:00
parent 5d04234863
commit 417a189f9b

View File

@ -107,23 +107,25 @@ public class CommandInfo {
if (method == null) {
return false;
}
check(cmdArgs);
final Runnable runnable = new Runnable() {
@Override
public void run() {
try {
method.invoke(origin, cmdArgs);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new CommandException(e);
if (check(cmdArgs)) {
final Runnable runnable = new Runnable() {
@Override
public void run() {
try {
method.invoke(origin, cmdArgs);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new CommandException(e);
}
}
};
if (async) {
Bukkit.getScheduler().runTaskAsynchronously(P.instance, runnable);
} else {
runnable.run();
}
};
if (async) {
Bukkit.getScheduler().runTaskAsynchronously(P.instance, runnable);
} else {
runnable.run();
return true;
}
return true;
return false;
}
/**
@ -185,15 +187,19 @@ public class CommandInfo {
Log.toSender(sender, cmdErr);
Log.toSender(sender, String.format(cmdUse, cmdArgs.getAlias(), getName(), help.possibleArguments()));
Log.toSender(sender, String.format(cmdDes, help.value()));
return false;
}
if (sender instanceof Player && command.onlyConsole()) {
Log.toSender(sender, onlyConsole);
return false;
} else if (command.onlyPlayer()) {
Log.toSender(sender, onlyPlayer);
return false;
}
final String perm = command.permission();
if (perm != null && !sender.hasPermission(perm)) {
Log.toSender(sender, String.format(losePerm, perm));
return false;
}
return true;
}