CommandAPI 11.1.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 ()
 
void onEnable ()
 
void onDisable ()
 
CommandAPIPlatform< Argument, CommandSender, Source > getPlatform ()
 
Command< Source > generateCommand (Argument[] args, CommandAPIExecutor< CommandSender, AbstractCommandSender<? extends CommandSender > > executor, boolean converted)
 Generates a command to be registered by the CommandAPI. More...
 
void writeDispatcherToFile ()
 

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

◆ generateCommand()

Command< Source > dev.jorel.commandapi.CommandAPIHandler< Argument, CommandSender, Source >.generateCommand ( Argument[]  args,
CommandAPIExecutor< CommandSender, AbstractCommandSender<? extends CommandSender > >  executor,
boolean  converted 
)

Generates a command to be registered by the CommandAPI.

Parameters
argsset of ordered argument pairs which contain the prompt text and their argument types
executorcode to be ran when the command is executed
convertedTrue if this command is being converted from another plugin, and false otherwise
Returns
a brigadier command which is registered internally

◆ 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