Package dev.jorel.commandapi
Interface CommandAPIPlatform<Argument extends AbstractArgument<?,?,Argument,CommandSender>,CommandSender,Source>
- Type Parameters:
Argument- The implementation of AbstractArgument used for the platformCommandSender- The class for running platforms commandsSource- The class for running Brigadier commands
public interface CommandAPIPlatform<Argument extends AbstractArgument<?,?,Argument,CommandSender>,CommandSender,Source>
-
Method Summary
Modifier and TypeMethodDescriptionvoidcreateDispatcherFile(File file, com.mojang.brigadier.CommandDispatcher<Source> dispatcher) Creates a JSON file that describes the hierarchical structure of the commands that have been registered by the server.com.mojang.brigadier.CommandDispatcher<Source>getBrigadierSourceFromCommandSender(AbstractCommandSender<? extends CommandSender> sender) Converts a CommandSender wrapped in an AbstractCommandSender to an object Brigadier can use when running its commandsAbstractCommandSender<? extends CommandSender>Converts the class used by Brigadier when running commands into an AbstractCommandSender wrapping the platform's CommandSenderdefault CommandAPILoggerAbstractCommandSender<? extends CommandSender>getSenderForCommand(com.mojang.brigadier.context.CommandContext<Source> cmdCtx, boolean forceNative) Converts a Brigadier CommandContext into an AbstractCommandSender wrapping the platform's CommandSendercom.mojang.brigadier.suggestion.SuggestionProvider<Source>getSuggestionProvider(SuggestionProviders suggestionProvider) newConcreteCommandAPICommand(dev.jorel.commandapi.CommandMetaData<CommandSender> meta) newConcreteLiteralArgument(String nodeName, String literal) newConcreteMultiLiteralArgument(String nodeName, String[] literals) voidPlatform-specific stuff that should happen when the CommandAPI is disabled.voidonEnable()Platform-specific stuff that should happen when the CommandAPI is enabled, such as registering event listeners.voidonLoad(CommandAPIConfig<?> config) Platform-specific stuff that should happen when the CommandAPI is loaded, such as checking dependencies and initializing helper classes.voidpostCommandRegistration(com.mojang.brigadier.tree.LiteralCommandNode<Source> resultantNode, List<com.mojang.brigadier.tree.LiteralCommandNode<Source>> aliasNodes) Stuff to run after a command has been generated.voidpreCommandRegistration(String commandName) Stuff to run before a command is generated.com.mojang.brigadier.tree.LiteralCommandNode<Source>registerCommandNode(com.mojang.brigadier.builder.LiteralArgumentBuilder<Source> node) Registers a Brigadier command node and returns the built node.voidregisterPermission(String string) voidReloads the server's data packs to include CommandAPI commandsvoidunregister(String commandName, boolean force) Unregisters a command from the CommandGraph so it can't be run anymore.voidupdateRequirements(AbstractPlayer<?> player) Updates the requirements required for a given player to execute a command.AbstractCommandSender<? extends CommandSender>wrapCommandSender(CommandSender sender) Wraps a CommandSender in an AbstractCommandSender class, the inverse operation toAbstractCommandSender.getSource()
-
Method Details
-
onLoad
Platform-specific stuff that should happen when the CommandAPI is loaded, such as checking dependencies and initializing helper classes.- Parameters:
config- the configuration to use for the CommandAPI.
-
onEnable
void onEnable()Platform-specific stuff that should happen when the CommandAPI is enabled, such as registering event listeners. -
onDisable
void onDisable()Platform-specific stuff that should happen when the CommandAPI is disabled. -
getSenderForCommand
AbstractCommandSender<? extends CommandSender> getSenderForCommand(com.mojang.brigadier.context.CommandContext<Source> cmdCtx, boolean forceNative) Converts a Brigadier CommandContext into an AbstractCommandSender wrapping the platform's CommandSender- Parameters:
cmdCtx- A Brigadier CommandContextforceNative- True if the CommandSender should be forced into a native CommandSender- Returns:
- An AbstractCommandSender wrapping the CommandSender represented by the CommandContext
-
getCommandSenderFromCommandSource
Converts the class used by Brigadier when running commands into an AbstractCommandSender wrapping the platform's CommandSender- Parameters:
source- The Brigadier source object- Returns:
- An AbstractCommandSender wrapping the CommandSender represented by the source object
-
getBrigadierSourceFromCommandSender
Converts a CommandSender wrapped in an AbstractCommandSender to an object Brigadier can use when running its commands- Parameters:
sender- The CommandSender to convert, wrapped in an AbstractCommandSender- Returns:
- The Brigadier Source object represented by the sender
-
wrapCommandSender
Wraps a CommandSender in an AbstractCommandSender class, the inverse operation toAbstractCommandSender.getSource()- Parameters:
sender- The CommandSender to wrap- Returns:
- An AbstractCommandSender with a class appropriate to the underlying class of the CommandSender
-
registerPermission
-
getSuggestionProvider
com.mojang.brigadier.suggestion.SuggestionProvider<Source> getSuggestionProvider(SuggestionProviders suggestionProvider) -
preCommandRegistration
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:
commandName- The name of the command about to be registered
-
postCommandRegistration
void postCommandRegistration(com.mojang.brigadier.tree.LiteralCommandNode<Source> resultantNode, List<com.mojang.brigadier.tree.LiteralCommandNode<Source>> aliasNodes) Stuff to run after a command has been generated.- Parameters:
resultantNode- the node that was registeredaliasNodes- any alias nodes that were also registered as a part of this registration process
-
registerCommandNode
com.mojang.brigadier.tree.LiteralCommandNode<Source> registerCommandNode(com.mojang.brigadier.builder.LiteralArgumentBuilder<Source> node) Registers a Brigadier command node and returns the built node. -
unregister
Unregisters a command from the CommandGraph so it can't be run anymore.- Parameters:
commandName- the name of the command to unregisterforce- whether the unregistration system should attempt to remove all instances of the command, regardless of whether they have been registered by Minecraft, Bukkit or Spigot etc.
-
getBrigadierDispatcher
com.mojang.brigadier.CommandDispatcher<Source> getBrigadierDispatcher()- Returns:
- The Brigadier CommandDispatcher tree being used by the platform's server
-
createDispatcherFile
void createDispatcherFile(File file, com.mojang.brigadier.CommandDispatcher<Source> dispatcher) throws IOException Creates a JSON file that describes the hierarchical structure of the commands that have been registered by the server.- Parameters:
file- The JSON file to write todispatcher- The Brigadier CommandDispatcher- Throws:
IOException- When the file fails to be written to
-
getLogger
- Returns:
- A new default Logger meant for the CommandAPI to use
-
reloadDataPacks
void reloadDataPacks()Reloads the server's data packs to include CommandAPI commands -
updateRequirements
Updates the requirements required for a given player to execute a command.- Parameters:
player- the player to update
-
newConcreteCommandAPICommand
AbstractCommandAPICommand<?,Argument, newConcreteCommandAPICommandCommandSender> (dev.jorel.commandapi.CommandMetaData<CommandSender> meta) -
newConcreteMultiLiteralArgument
-
newConcreteLiteralArgument
-