mirror of
https://github.com/aikar/commands.git
synced 2026-05-31 06:11:55 +00:00
Fix some bugs with RegisteredCommand
This commit is contained in:
@@ -150,8 +150,9 @@ public class RegisteredCommand<CEC extends CommandExecutionContext<CEC, ? extend
|
||||
method.invoke(scope, passedArgs.values().toArray());
|
||||
} catch (Exception e) {
|
||||
handleException(sender, args, e);
|
||||
} finally {
|
||||
postCommand();
|
||||
}
|
||||
postCommand();
|
||||
}
|
||||
|
||||
public void preCommand() {
|
||||
@@ -232,11 +233,12 @@ public class RegisteredCommand<CEC extends CommandExecutionContext<CEC, ? extend
|
||||
if (allowOptional && parameter.getDefaultValue() != null) {
|
||||
args.add(parameter.getDefaultValue());
|
||||
} else if (allowOptional && parameter.isOptional()) {
|
||||
if (!this.manager.hasPermission(sender, parameterPermissions)) {
|
||||
sender.sendMessage(MessageType.ERROR, MessageKeys.PERMISSION_DENIED_PARAMETER, "{param}", parameterName);
|
||||
throw new InvalidCommandArgument(false);
|
||||
Object value;
|
||||
if (!parameter.isOptionalResolver() || !this.manager.hasPermission(sender, parameterPermissions)) {
|
||||
value = null;
|
||||
} else {
|
||||
value = resolver.getContext(context);
|
||||
}
|
||||
Object value = parameter.isOptionalResolver() ? resolver.getContext(context) : null;
|
||||
|
||||
if (value == null && parameter.getClass().isPrimitive()) {
|
||||
throw new IllegalStateException("Parameter " + parameter.getName() + " is primitive and does not support Optional.");
|
||||
|
||||
Reference in New Issue
Block a user