Interface CommandAPIPlatform<Argument extends AbstractArgument<?,?,Argument,CommandSender>,CommandSender,Source>

Type Parameters:
Argument - The implementation of AbstractArgument used for the platform
CommandSender - The class for running platforms commands
Source - The class for running Brigadier commands

public interface CommandAPIPlatform<Argument extends AbstractArgument<?,?,Argument,CommandSender>,CommandSender,Source>
  • Method Details

    • onLoad

      void onLoad(CommandAPIConfig<?> config)
      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 CommandContext
      forceNative - True if the CommandSender should be forced into a native CommandSender
      Returns:
      An AbstractCommandSender wrapping the CommandSender represented by the CommandContext
    • getCommandSenderFromCommandSource

      AbstractCommandSender<? extends CommandSender> getCommandSenderFromCommandSource(Source source)
      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

      Source getBrigadierSourceFromCommandSender(AbstractCommandSender<? extends CommandSender> sender)
      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

      AbstractCommandSender<? extends CommandSender> wrapCommandSender(CommandSender sender)
      Wraps a CommandSender in an AbstractCommandSender class, the inverse operation to AbstractCommandSender.getSource()
      Parameters:
      sender - The CommandSender to wrap
      Returns:
      An AbstractCommandSender with a class appropriate to the underlying class of the CommandSender
    • registerPermission

      void registerPermission(String string)
    • getSuggestionProvider

      com.mojang.brigadier.suggestion.SuggestionProvider<Source> getSuggestionProvider(SuggestionProviders suggestionProvider)
    • preCommandRegistration

      void preCommandRegistration(String commandName)
      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 registered
      aliasNodes - 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

      void unregister(String commandName, boolean force)
      Unregisters a command from the CommandGraph so it can't be run anymore.
      Parameters:
      commandName - the name of the command to unregister
      force - 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 to
      dispatcher - The Brigadier CommandDispatcher
      Throws:
      IOException - When the file fails to be written to
    • getLogger

      default CommandAPILogger 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

      void updateRequirements(AbstractPlayer<?> player)
      Updates the requirements required for a given player to execute a command.
      Parameters:
      player - the player to update
    • newConcreteCommandAPICommand

      AbstractCommandAPICommand<?,Argument,CommandSender> newConcreteCommandAPICommand(dev.jorel.commandapi.CommandMetaData<CommandSender> meta)
    • newConcreteMultiLiteralArgument

      Argument newConcreteMultiLiteralArgument(String nodeName, String[] literals)
    • newConcreteLiteralArgument

      Argument newConcreteLiteralArgument(String nodeName, String literal)