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 Details

    • ContextFactory

      protected ContextFactory()
  • Method Details

    • defaultFactory

      public static <S extends CommandSource> ContextFactory<S> 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 execution
      command - the command label used
      queue - the args input
      Returns:
      new context from the command and args used by CommandSource
    • createDummyContext

      @NotNull public @NotNull CommandContext<S> createDummyContext(@NotNull @NotNull Imperat<S> imperat)
      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 source
      command - the command
      queue - 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 plain
      pathway - the matched command pathway
      lastCommand - the last (most specific) command matched
      Returns:
      the execution context ready for argument resolution