Merge branch 'command-redirection'

This commit is contained in:
themode 2021-03-17 05:06:33 +01:00
commit 72ad230872
2 changed files with 6 additions and 4 deletions

View File

@ -91,7 +91,7 @@ public class CommandDispatcher {
CommandResult commandResult = parse(commandString);
ParsedCommand parsedCommand = commandResult.parsedCommand;
if (parsedCommand != null) {
commandResult.commandData = parsedCommand.execute(source, commandString);
commandResult.commandData = parsedCommand.execute(source);
}
return commandResult;
}
@ -162,6 +162,7 @@ public class CommandDispatcher {
ParsedCommand parsedCommand = new ParsedCommand();
parsedCommand.command = command;
parsedCommand.commandString = commandString;
// The default executor should be used if no argument is provided
{

View File

@ -13,6 +13,7 @@ public class ParsedCommand {
// Command
protected Command command;
protected String commandString;
// Command Executor
protected CommandSyntax syntax;
@ -30,12 +31,11 @@ public class ParsedCommand {
* The command will not be executed if {@link Command#getCondition()}
* is not validated.
*
* @param source the command source
* @param commandString the command string
* @param source the command source
* @return the command data, null if none
*/
@Nullable
public CommandData execute(@NotNull CommandSender source, @NotNull String commandString) {
public CommandData execute(@NotNull CommandSender source) {
// Global listener
command.globalListener(source, context, commandString);
// Command condition check
@ -78,6 +78,7 @@ public class ParsedCommand {
public static ParsedCommand withDefaultExecutor(@NotNull Command command, @NotNull String input) {
ParsedCommand parsedCommand = new ParsedCommand();
parsedCommand.command = command;
parsedCommand.commandString = input;
parsedCommand.executor = command.getDefaultExecutor();
parsedCommand.context = new CommandContext(input);
return parsedCommand;