Minestom/src/main/java/net/minestom/server/command/CommandParser.java
mworzala 8335afdf47 hollow-cube/sender-in-command-arg-parsing
Signed-off-by: mworzala <mattheworzala@gmail.com>

fix default argument issue

(cherry picked from commit a7440639c8541faeb91155c53ce3a1f4d60df127)

Add sender to command parse chain

(cherry picked from commit 853307891d178abdc7036f8c809c52909cdca327)

(cherry picked from commit 1268cf16c0)
2024-02-09 14:27:43 -05:00

55 lines
1.7 KiB
Java

package net.minestom.server.command;
import net.minestom.server.command.builder.arguments.Argument;
import net.minestom.server.command.builder.suggestion.Suggestion;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
@ApiStatus.Internal
@ApiStatus.Experimental
public interface CommandParser {
static @NotNull CommandParser parser() {
return CommandParserImpl.PARSER;
}
/**
* Parses the command by following the graph
*
* @param graph structure to use for parsing
* @param input command string without prefix
* @return the parsed command which can be executed and cached
*/
@Contract("_, _ -> new")
@NotNull Result parse(@NotNull CommandSender sender, @NotNull Graph graph, @NotNull String input);
sealed interface Result {
@NotNull ExecutableCommand executable();
@ApiStatus.Internal
@Nullable Suggestion suggestion(CommandSender sender);
@ApiStatus.Internal
List<Argument<?>> args();
sealed interface UnknownCommand extends Result
permits CommandParserImpl.UnknownCommandResult {
}
sealed interface KnownCommand extends Result
permits CommandParserImpl.InternalKnownCommand, Result.KnownCommand.Invalid, Result.KnownCommand.Valid {
sealed interface Valid extends KnownCommand
permits CommandParserImpl.ValidCommand {
}
sealed interface Invalid extends KnownCommand
permits CommandParserImpl.InvalidCommand {
}
}
}
}