Class ContextFactory<S extends CommandSource>
java.lang.Object
studio.mevera.imperat.context.internal.ContextFactory<S>
- Type Parameters:
S-
@AvailableSince("1.0.0")
public abstract class ContextFactory<S extends CommandSource>
extends Object
Represents a way for defining
how the context is created
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract @NotNull CommandContext<S>createContext(@NotNull Imperat<S> imperat, S source, Command<S> command, @NotNull String label, @NotNull ArgumentInput queue) @NotNull CommandContext<S>createDummyContext(@NotNull Imperat<S> imperat) abstract ExecutionContext<S>createExecutionContext(@NotNull CommandContext<S> plainContext, @Nullable CommandPathway<S> pathway, @NotNull Command<S> lastCommand) Creates the execution context from a plain context with the matched pathway and last command.abstract SuggestionContext<S>createSuggestionContext(@NotNull Imperat<S> imperat, S source, @NotNull Command<S> command, @NotNull String label, @NotNull ArgumentInput queue) static <S extends CommandSource>
ContextFactory<S>
-
Constructor Details
-
ContextFactory
protected ContextFactory()
-
-
Method Details
-
defaultFactory
-
createContext
@NotNull public abstract @NotNull CommandContext<S> createContext(@NotNull @NotNull Imperat<S> imperat, @NotNull S source, Command<S> command, @NotNull @NotNull String label, @NotNull @NotNull ArgumentInput queue) - Parameters:
source- the sender/source of this command executioncommand- the command label usedqueue- the args input- Returns:
- new context from the command and args used by
CommandSource
-
createDummyContext
- Parameters:
imperat- the imperat instance- Returns:
- a dummy context with a dummy sender for testing or other purposes
-
createSuggestionContext
public abstract SuggestionContext<S> createSuggestionContext(@NotNull @NotNull Imperat<S> imperat, @NotNull S source, @NotNull @NotNull Command<S> command, @NotNull @NotNull String label, @NotNull @NotNull ArgumentInput queue) - Parameters:
source- the sourcecommand- the commandqueue- the argument input- Returns:
- new context for auto completions with
CompletionArg
-
createExecutionContext
public abstract ExecutionContext<S> createExecutionContext(@NotNull @NotNull CommandContext<S> plainContext, @Nullable @Nullable CommandPathway<S> pathway, @NotNull @NotNull Command<S> lastCommand) Creates the execution context from a plain context with the matched pathway and last command.- Parameters:
plainContext- the context plainpathway- the matched command pathwaylastCommand- the last (most specific) command matched- Returns:
- the execution context ready for argument resolution
-