All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minestom.server.command.CommandParser Maven / Gradle / Ivy

There is a newer version: 7320437640
Show newest version
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
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> 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 {
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy