Interface CommandRegistry


public interface CommandRegistry
Handles the registration and execution of commands.
  • Method Details

    • register

      default void register(com.mojang.brigadier.builder.LiteralArgumentBuilder<CommandSource> command)
      Registers a command from the given builder.
      Parameters:
      command - the command builder to register
    • register

      default void register(com.mojang.brigadier.tree.LiteralCommandNode<CommandSource> command)
      Registers a command node without aliases.
      Parameters:
      command - the command node to register
    • register

      default void register(com.mojang.brigadier.builder.LiteralArgumentBuilder<CommandSource> command, Set<String> aliases)
      Registers a command from the given builder with the specified aliases.
      Parameters:
      command - the command builder to register
      aliases - additional aliases that should point to this command
    • register

      void register(com.mojang.brigadier.tree.LiteralCommandNode<CommandSource> command, Set<String> aliases)
      Registers a command node with the specified aliases.

      Aliases are additional names that can be used to execute the command besides its primary literal name.

      Parameters:
      command - the command node to register
      aliases - additional aliases that should point to this command
    • unregister

      void unregister(String alias)
      Unregisters the specified command alias from the manager, if registered. Root literal names are also treated as aliases in this context.
      Parameters:
      alias - the command alias to unregister; if not currently registered, this method does nothing
    • dispatchAsync

      CompletableFuture<Boolean> dispatchAsync(CommandSource source, String cmdLine)
      Attempts to asynchronously execute a command from the given cmdLine.
      Parameters:
      source - the source to execute the command for
      cmdLine - the command to run
      Returns:
      a future that may be completed with the result of the command execution. Can be completed exceptionally if an exception is thrown during execution.
    • offerSuggestions

      CompletableFuture<List<String>> offerSuggestions(CommandSource source, String cmdLine)
      Asynchronously collects suggestions to fill in the given command cmdLine. Returns only the raw completion suggestions without tooltips.
      Parameters:
      source - the source to execute the command for
      cmdLine - the partially completed command
      Returns:
      a CompletableFuture eventually completed with a List, possibly empty
    • offerBrigadierSuggestions

      CompletableFuture<com.mojang.brigadier.suggestion.Suggestions> offerBrigadierSuggestions(CommandSource source, String cmdLine)
      Asynchronously collects suggestions to fill in the given command cmdLine. Returns the brigadier Suggestions with tooltips for each result.
      Parameters:
      source - the source to execute the command for
      cmdLine - the partially completed command
      Returns:
      a CompletableFuture eventually completed with Suggestions, possibly empty
    • hasCommand

      boolean hasCommand(String alias)
      Returns whether the given alias is registered on this manager.
      Parameters:
      alias - the command alias to check
      Returns:
      true if the alias is registered; false otherwise
    • hasCommand

      boolean hasCommand(String alias, CommandSource source)
      Returns whether the given alias is registered on this manager and can be used by the given CommandSource. See ArgumentBuilder.requires(Predicate)
      Parameters:
      alias - the command alias to check
      source - the command source
      Returns:
      true if the alias is registered and usable; false otherwise