CommandAPI 9.7.0
An API for the command UI introduced in Minecraft 1.13
dev.jorel.commandapi.CommandAPIPlatform< Argument, CommandSender, Source > Interface Template Reference

Public Member Functions

abstract void onLoad (CommandAPIConfig<?> config)
 Platform-specific stuff that should happen when the CommandAPI is loaded, such as checking dependencies and initializing helper classes. More...
 
abstract void onEnable ()
 Platform-specific stuff that should happen when the CommandAPI is enabled, such as registering event listeners.
 
abstract void onDisable ()
 Platform-specific stuff that should happen when the CommandAPI is disabled.
 
abstract AbstractCommandSender<? extends CommandSender > getSenderForCommand (CommandContext< Source > cmdCtx, boolean forceNative)
 Converts a Brigadier CommandContext into an AbstractCommandSender wrapping the platform's CommandSender. More...
 
abstract AbstractCommandSender<? extends CommandSender > getCommandSenderFromCommandSource (Source source)
 Converts the class used by Brigadier when running commands into an AbstractCommandSender wrapping the platform's CommandSender. More...
 
abstract Source getBrigadierSourceFromCommandSender (AbstractCommandSender<? extends CommandSender > sender)
 Converts a CommandSender wrapped in an AbstractCommandSender to an object Brigadier can use when running its commands. More...
 
abstract AbstractCommandSender<? extends CommandSender > wrapCommandSender (CommandSender sender)
 Wraps a CommandSender in an AbstractCommandSender class, the inverse operation to AbstractCommandSender#getSource(). More...
 
abstract void registerPermission (String string)
 
abstract SuggestionProvider< Source > getSuggestionProvider (SuggestionProviders suggestionProvider)
 
abstract void preCommandRegistration (String commandName)
 Stuff to run before a command is generated. More...
 
abstract void postCommandRegistration (RegisteredCommand registeredCommand, LiteralCommandNode< Source > resultantNode, List< LiteralCommandNode< Source > > aliasNodes)
 Stuff to run after a command has been generated. More...
 
abstract LiteralCommandNode< Source > registerCommandNode (LiteralArgumentBuilder< Source > node, String namespace)
 Registers a Brigadier command node and returns the built node.
 
abstract void unregister (String commandName, boolean unregisterNamespaces)
 Unregisters a command from the CommandGraph so it can't be run anymore. More...
 
abstract CommandDispatcher< Source > getBrigadierDispatcher ()
 
abstract void createDispatcherFile (File file, CommandDispatcher< Source > dispatcher) throws IOException
 Creates a JSON file that describes the hierarchical structure of the commands that have been registered by the server. More...
 
default CommandAPILogger getLogger ()
 
abstract void reloadDataPacks ()
 Reloads the server's data packs to include CommandAPI commands.
 
abstract void updateRequirements (AbstractPlayer<?> player)
 Updates the requirements required for a given player to execute a command. More...
 
abstract AbstractCommandAPICommand<?, Argument, CommandSender > newConcreteCommandAPICommand (CommandMetaData< CommandSender > meta)
 
abstract Argument newConcreteMultiLiteralArgument (String nodeName, String[] literals)
 
abstract Argument newConcreteLiteralArgument (String nodeName, String literal)
 

Detailed Description

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

Member Function Documentation

◆ createDispatcherFile()

abstract void dev.jorel.commandapi.CommandAPIPlatform< Argument, CommandSender, Source >.createDispatcherFile ( File  file,
CommandDispatcher< Source >  dispatcher 
) throws IOException
abstract

Creates a JSON file that describes the hierarchical structure of the commands that have been registered by the server.

Parameters
fileThe JSON file to write to
dispatcherThe Brigadier CommandDispatcher
Exceptions
IOExceptionWhen the file fails to be written to

◆ getBrigadierDispatcher()

abstract CommandDispatcher< Source > dev.jorel.commandapi.CommandAPIPlatform< Argument, CommandSender, Source >.getBrigadierDispatcher ( )
abstract
Returns
The Brigadier CommandDispatcher tree being used by the platform's server

◆ getBrigadierSourceFromCommandSender()

abstract Source dev.jorel.commandapi.CommandAPIPlatform< Argument, CommandSender, Source >.getBrigadierSourceFromCommandSender ( AbstractCommandSender<? extends CommandSender >  sender)
abstract

Converts a CommandSender wrapped in an AbstractCommandSender to an object Brigadier can use when running its commands.

Parameters
senderThe CommandSender to convert, wrapped in an AbstractCommandSender
Returns
The Brigadier Source object represented by the sender

◆ getCommandSenderFromCommandSource()

abstract AbstractCommandSender<? extends CommandSender > dev.jorel.commandapi.CommandAPIPlatform< Argument, CommandSender, Source >.getCommandSenderFromCommandSource ( Source  source)
abstract

Converts the class used by Brigadier when running commands into an AbstractCommandSender wrapping the platform's CommandSender.

Parameters
sourceThe Brigadier source object
Returns
An AbstractCommandSender wrapping the CommandSender represented by the source object

◆ getLogger()

default CommandAPILogger dev.jorel.commandapi.CommandAPIPlatform< Argument, CommandSender, Source >.getLogger ( )
Returns
A new default Logger meant for the CommandAPI to use. This logger will be used by the CommandAPI if one is not set using CommandAPI#setLogger(CommandAPILogger).

◆ getSenderForCommand()

abstract AbstractCommandSender<? extends CommandSender > dev.jorel.commandapi.CommandAPIPlatform< Argument, CommandSender, Source >.getSenderForCommand ( CommandContext< Source >  cmdCtx,
boolean  forceNative 
)
abstract

Converts a Brigadier CommandContext into an AbstractCommandSender wrapping the platform's CommandSender.

Parameters
cmdCtxA Brigadier CommandContext
forceNativeTrue if the CommandSender should be forced into a native CommandSender
Returns
An AbstractCommandSender wrapping the CommandSender represented by the CommandContext

◆ onLoad()

abstract void dev.jorel.commandapi.CommandAPIPlatform< Argument, CommandSender, Source >.onLoad ( CommandAPIConfig<?>  config)
abstract

Platform-specific stuff that should happen when the CommandAPI is loaded, such as checking dependencies and initializing helper classes.

Parameters
configthe configuration to use for the CommandAPI.

◆ postCommandRegistration()

abstract void dev.jorel.commandapi.CommandAPIPlatform< Argument, CommandSender, Source >.postCommandRegistration ( RegisteredCommand  registeredCommand,
LiteralCommandNode< Source >  resultantNode,
List< LiteralCommandNode< Source > >  aliasNodes 
)
abstract

Stuff to run after a command has been generated.

Parameters
registeredCommandA RegisteredCommand instance that holds the CommandAPI information for the command
resultantNodeThe node that was registered
aliasNodesAny alias nodes that were also registered as a part of this registration process

◆ preCommandRegistration()

abstract void dev.jorel.commandapi.CommandAPIPlatform< Argument, CommandSender, Source >.preCommandRegistration ( String  commandName)
abstract

Stuff to run before a command is generated.

For Bukkit, this involves checking if a command was declared in the plugin.yml when it isn't supposed to be.

Parameters
commandNameThe name of the command about to be registered

◆ unregister()

abstract void dev.jorel.commandapi.CommandAPIPlatform< Argument, CommandSender, Source >.unregister ( String  commandName,
boolean  unregisterNamespaces 
)
abstract

Unregisters a command from the CommandGraph so it can't be run anymore.

Parameters
commandNamethe name of the command to unregister
unregisterNamespaceswhether the unregistration system should attempt to remove versions of the command that start with a namespace. Eg. minecraft:command, bukkit:command, or plugin:command

◆ updateRequirements()

abstract void dev.jorel.commandapi.CommandAPIPlatform< Argument, CommandSender, Source >.updateRequirements ( AbstractPlayer<?>  player)
abstract

Updates the requirements required for a given player to execute a command.

Parameters
playerthe player to update

◆ wrapCommandSender()

abstract AbstractCommandSender<? extends CommandSender > dev.jorel.commandapi.CommandAPIPlatform< Argument, CommandSender, Source >.wrapCommandSender ( CommandSender  sender)
abstract

Wraps a CommandSender in an AbstractCommandSender class, the inverse operation to AbstractCommandSender#getSource().

Parameters
senderThe CommandSender to wrap
Returns
An AbstractCommandSender with a class appropriate to the underlying class of the CommandSender