mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-28 14:37:31 +02:00
Fix empty command chain causing NullPointerException (#1931)
* Fix empty command chain causing NullPointerException * Add test for empty command input (cherry picked from commit3645d4311d
) (cherry picked from commite2efdbb427
)
This commit is contained in:
parent
6805c903f3
commit
2be361448f
@ -97,18 +97,19 @@ final class CommandParserImpl implements CommandParser {
|
||||
|
||||
NodeResult result = parseNode(sender, parent, chain, reader);
|
||||
chain = result.chain;
|
||||
if (result.argumentResult instanceof ArgumentResult.Success<?>) {
|
||||
NodeResult lastNodeResult = chain.nodeResults.peekLast();
|
||||
Node lastNode = lastNodeResult.node;
|
||||
|
||||
NodeResult lastNodeResult = chain.nodeResults.peekLast();
|
||||
if (lastNodeResult == null) return UnknownCommandResult.INSTANCE;
|
||||
Node lastNode = lastNodeResult.node;
|
||||
|
||||
if (result.argumentResult instanceof ArgumentResult.Success<?>) {
|
||||
CommandExecutor executor = nullSafeGetter(lastNode.execution(), Graph.Execution::executor);
|
||||
if (executor != null) return ValidCommand.executor(input, chain, executor);
|
||||
}
|
||||
// If here, then the command failed or didn't have an executor
|
||||
|
||||
// Look for a default executor, or give up if we got nowhere
|
||||
NodeResult lastNode = chain.nodeResults.peekLast();
|
||||
if (lastNode.node.equals(parent)) return UnknownCommandResult.INSTANCE;
|
||||
if (lastNode.equals(parent)) return UnknownCommandResult.INSTANCE;
|
||||
if (chain.defaultExecutor != null) {
|
||||
return ValidCommand.defaultExecutor(input, chain);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user