Class CommandAPIHandler<Argument extends AbstractArgument<?,?,Argument,CommandSender>,CommandSender,Source>

java.lang.Object
dev.jorel.commandapi.CommandAPIHandler<Argument,CommandSender,Source>
Type Parameters:
Argument - The implementation of AbstractArgument being used
CommandSender - The class for running platform commands
Source - The class for running Brigadier commands

public class CommandAPIHandler<Argument extends AbstractArgument<?,?,Argument,CommandSender>,CommandSender,Source> extends Object
The "brains" behind the CommandAPI. Handles command registration
  • Constructor Details

  • Method Details

    • getRawArgumentInput

      public static <CommandSource> String getRawArgumentInput(com.mojang.brigadier.context.CommandContext<CommandSource> cmdCtx, String key)
      Returns the raw input for an argument for a given command context and its key. This effectively returns the string value that is currently typed for this argument
      Type Parameters:
      CommandSource - the command source type
      Parameters:
      cmdCtx - the command context which is used to run this command
      key - the node name for the argument
      Returns:
      the raw input string for this argument
    • onLoad

      public void onLoad(CommandAPIConfig<?> config)
    • onEnable

      public void onEnable()
    • onDisable

      public void onDisable()
    • getInstance

      public static CommandAPIHandler<?,?,?> getInstance()
    • getPlatform

    • lookupPreviewable

      public Optional<PreviewableFunction<?>> lookupPreviewable(List<String> path)
      Looks up the function to generate a chat preview for a path of nodes in the command tree. This is a method internal to the CommandAPI and isn't expected to be used by plugin developers (but you're more than welcome to use it as you see fit).
      Parameters:
      path - a list of Strings representing the path (names of command nodes) to (and including) the previewable argument
      Returns:
      a function that takes in a PreviewInfo and returns a Component. If such a function is not available, this will return a function that always returns null.
    • lookupPreviewableLegacyStatus

      public boolean lookupPreviewableLegacyStatus(List<String> path)
      Parameters:
      path - a list of Strings representing the path (names of command nodes) to (and including) the previewable argument
      Returns:
      Whether a previewable is legacy (non-Adventure) or not
    • getField

      public static Field getField(Class<?> clazz, String name)
      Caches a field using reflection if it is not already cached, then return the field of a given class. This will also make the field accessible.
      Parameters:
      clazz - the class where the field is declared
      name - the name of the field
      Returns:
      a Field reference
    • getField

      public static Field getField(Class<?> clazz, String name, String mojangMappedName)
      Caches a field using reflection if it is not already cached, then return the field of a given class. This will also make the field accessible.
      Parameters:
      clazz - the class where the field is declared
      name - the name of the field
      mojangMappedName - the name of a field under Mojang mappings
      Returns:
      a Field reference