mirror of
https://github.com/Minestom/Minestom.git
synced 2024-10-06 02:17:47 +02:00
Merge branch 'command-redirection'
This commit is contained in:
commit
72ad230872
@ -91,7 +91,7 @@ public class CommandDispatcher {
|
|||||||
CommandResult commandResult = parse(commandString);
|
CommandResult commandResult = parse(commandString);
|
||||||
ParsedCommand parsedCommand = commandResult.parsedCommand;
|
ParsedCommand parsedCommand = commandResult.parsedCommand;
|
||||||
if (parsedCommand != null) {
|
if (parsedCommand != null) {
|
||||||
commandResult.commandData = parsedCommand.execute(source, commandString);
|
commandResult.commandData = parsedCommand.execute(source);
|
||||||
}
|
}
|
||||||
return commandResult;
|
return commandResult;
|
||||||
}
|
}
|
||||||
@ -162,6 +162,7 @@ public class CommandDispatcher {
|
|||||||
|
|
||||||
ParsedCommand parsedCommand = new ParsedCommand();
|
ParsedCommand parsedCommand = new ParsedCommand();
|
||||||
parsedCommand.command = command;
|
parsedCommand.command = command;
|
||||||
|
parsedCommand.commandString = commandString;
|
||||||
|
|
||||||
// The default executor should be used if no argument is provided
|
// The default executor should be used if no argument is provided
|
||||||
{
|
{
|
||||||
|
@ -13,6 +13,7 @@ public class ParsedCommand {
|
|||||||
|
|
||||||
// Command
|
// Command
|
||||||
protected Command command;
|
protected Command command;
|
||||||
|
protected String commandString;
|
||||||
|
|
||||||
// Command Executor
|
// Command Executor
|
||||||
protected CommandSyntax syntax;
|
protected CommandSyntax syntax;
|
||||||
@ -30,12 +31,11 @@ public class ParsedCommand {
|
|||||||
* The command will not be executed if {@link Command#getCondition()}
|
* The command will not be executed if {@link Command#getCondition()}
|
||||||
* is not validated.
|
* is not validated.
|
||||||
*
|
*
|
||||||
* @param source the command source
|
* @param source the command source
|
||||||
* @param commandString the command string
|
|
||||||
* @return the command data, null if none
|
* @return the command data, null if none
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public CommandData execute(@NotNull CommandSender source, @NotNull String commandString) {
|
public CommandData execute(@NotNull CommandSender source) {
|
||||||
// Global listener
|
// Global listener
|
||||||
command.globalListener(source, context, commandString);
|
command.globalListener(source, context, commandString);
|
||||||
// Command condition check
|
// Command condition check
|
||||||
@ -78,6 +78,7 @@ public class ParsedCommand {
|
|||||||
public static ParsedCommand withDefaultExecutor(@NotNull Command command, @NotNull String input) {
|
public static ParsedCommand withDefaultExecutor(@NotNull Command command, @NotNull String input) {
|
||||||
ParsedCommand parsedCommand = new ParsedCommand();
|
ParsedCommand parsedCommand = new ParsedCommand();
|
||||||
parsedCommand.command = command;
|
parsedCommand.command = command;
|
||||||
|
parsedCommand.commandString = input;
|
||||||
parsedCommand.executor = command.getDefaultExecutor();
|
parsedCommand.executor = command.getDefaultExecutor();
|
||||||
parsedCommand.context = new CommandContext(input);
|
parsedCommand.context = new CommandContext(input);
|
||||||
return parsedCommand;
|
return parsedCommand;
|
||||||
|
Loading…
Reference in New Issue
Block a user