Interface ContextProvider<T,V>

Type Parameters:
T - The sender type
V - The type being provided
All Superinterfaces:
Named

public interface ContextProvider<T,V> extends Named
Extracts values from a command's execution context so they can be passed as arguments to the final dispatcher
  • Method Details

    • create

      static <T, V> ContextProvider<T,V> create(String name, String error, Function<CommandContext<T>,V> provider)
      Creates a context provider
      Type Parameters:
      T - The sender type
      V - The type being provided
      Parameters:
      name - The name of the provider
      error - The error to be shown if the provider returns null
      provider - The function to provide the value
      Returns:
      A context provider
    • provide

      V provide(CommandContext<T> context)
      Provides the context value for the given command execution context
      Parameters:
      context - The command execution context
      Returns:
      The generated context value
    • getError

      String getError()
      Returns:
      The error to be displayed if the context cannot be generated