CommandAPI 9.6.0
An API for the command UI introduced in Minecraft 1.13
dev.jorel.commandapi.CommandAPIHandler< Argument, CommandSender, Source > Class Template Reference

The "brains" behind the CommandAPI. More...

Public Member Functions

void onLoad (CommandAPIConfig<?> config)
 
void onEnable ()
 
void onDisable ()
 
CommandAPIPlatform< Argument, CommandSender, Source > getPlatform ()
 
void writeDispatcherToFile ()
 
Optional< PreviewableFunction<?> > lookupPreviewable (List< String > path)
 Looks up the function to generate a chat preview for a path of nodes in the command tree. More...
 
boolean lookupPreviewableLegacyStatus (List< String > path)
 

Static Public Member Functions

static< CommandSource > String getRawArgumentInput (CommandContext< CommandSource > cmdCtx, String key)
 Returns the raw input for an argument for a given command context and its key. More...
 
static CommandAPIHandler<?, ?, ?> getInstance ()
 
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. More...
 
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. More...
 

Protected Member Functions

 CommandAPIHandler (CommandAPIPlatform< Argument, CommandSender, Source > platform)
 

Detailed Description

The "brains" behind the CommandAPI.

Handles command registration

Parameters
<Argument>The implementation of AbstractArgument being used
<CommandSender>The class for running platform commands
<Source>The class for running Brigadier commands

Member Function Documentation

◆ getField() [1/2]

static Field dev.jorel.commandapi.CommandAPIHandler< Argument, CommandSender, Source >.getField ( Class<?>  clazz,
String  name 
)
static

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
clazzthe class where the field is declared
namethe name of the field
Returns
a Field reference

◆ getField() [2/2]

static Field dev.jorel.commandapi.CommandAPIHandler< Argument, CommandSender, Source >.getField ( Class<?>  clazz,
String  name,
String  mojangMappedName 
)
static

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
clazzthe class where the field is declared
namethe name of the field
mojangMappedNamethe name of a field under Mojang mappings
Returns
a Field reference

◆ getRawArgumentInput()

static< CommandSource > String dev.jorel.commandapi.CommandAPIHandler< Argument, CommandSender, Source >.getRawArgumentInput ( CommandContext< CommandSource >  cmdCtx,
String  key 
)
static

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

Parameters
<CommandSource>the command source type
cmdCtxthe command context which is used to run this command
keythe node name for the argument
Returns
the raw input string for this argument

◆ lookupPreviewable()

Optional< PreviewableFunction<?> > dev.jorel.commandapi.CommandAPIHandler< Argument, CommandSender, Source >.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
patha 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()

boolean dev.jorel.commandapi.CommandAPIHandler< Argument, CommandSender, Source >.lookupPreviewableLegacyStatus ( List< String >  path)
Parameters
patha 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