Class MinecraftHelp<C>

java.lang.Object
cloud.commandframework.minecraft.extras.MinecraftHelp<C>
Type Parameters:
C - Command sender type

public final class MinecraftHelp<C> extends Object
Opinionated extension of CommandHelpHandler for Minecraft
  • Field Details

  • Constructor Details

    • MinecraftHelp

      public MinecraftHelp(@NonNull String commandPrefix, @NonNull AudienceProvider<C> audienceProvider, @NonNull cloud.commandframework.CommandManager<C> commandManager)
      Construct a new Minecraft help instance.
      Parameters:
      commandPrefix - Command that was used to trigger the help menu. Used to help insertion generation
      audienceProvider - Provider that maps the command sender type to Audience
      commandManager - Command manager instance
  • Method Details

    • createNative

      public static <C extends net.kyori.adventure.audience.Audience> MinecraftHelp<C> createNative(@NonNull String commandPrefix, @NonNull cloud.commandframework.CommandManager<C> commandManager)
      Construct a new Minecraft help instance for a sender type which is an Audience.
      Type Parameters:
      C - sender type extending Audience
      Parameters:
      commandPrefix - Command that was used to trigger the help menu. Used to help insertion generation
      commandManager - command manager
      Returns:
      new MinecraftHelp instance
      Since:
      1.5.0
    • getCommandManager

      public @NonNull cloud.commandframework.CommandManager<C> getCommandManager()
      Get the command manager instance
      Returns:
      Command manager
    • getAudienceProvider

      public @NonNull AudienceProvider<C> getAudienceProvider()
      Get the audience provider that was used to create this instance
      Returns:
      Audience provider
    • getAudience

      public @NonNull net.kyori.adventure.audience.Audience getAudience(@NonNull C sender)
      Map a command sender to an Audience
      Parameters:
      sender - Sender to map
      Returns:
      Mapped audience
    • commandFilter

      public void commandFilter(@NonNull Predicate<cloud.commandframework.Command<C>> commandPredicate)
      Sets a filter for what commands are visible inside the help menu. When the Predicate tests true, then the command is included in the listings.

      The default filter will return true for all commands.

      Parameters:
      commandPredicate - Predicate to filter commands by
      Since:
      1.4.0
    • descriptionDecorator

      public void descriptionDecorator(@NonNull Function<@NonNull String,​@NonNull net.kyori.adventure.text.Component> decorator)
      Set the description decorator which will turn command and argument description strings into components.

      The default decorator simply calls Component.text(String)

      Parameters:
      decorator - description decorator
      Since:
      1.4.0
    • setMessage

      public void setMessage(@NonNull String key, @NonNull String value)
      Configure a message
      Parameters:
      key - Message key. These are constants in MinecraftHelp
      value - The text for the message
    • setMessageProvider

      public void setMessageProvider(@NonNull BiFunction<C,​String,​String> messageProvider)
      Set a custom message provider function to be used for getting messages from keys.

      The keys are constants in MinecraftHelp.

      Parameters:
      messageProvider - The message provider to use
    • messageProvider

      public void messageProvider(@NonNull MinecraftHelp.MessageProvider<C> messageProvider)
      Set a custom message provider function to be used for getting messages from keys.

      The keys are constants in MinecraftHelp.

      This version of the method which takes a MinecraftHelp.MessageProvider will have priority over a message provider registered through setMessageProvider(BiFunction)

      Parameters:
      messageProvider - The message provider to use
      Since:
      1.4.0
    • setHelpColors

      public void setHelpColors(@NonNull MinecraftHelp.HelpColors colors)
      Set the colors to use for help messages.
      Parameters:
      colors - The new MinecraftHelp.HelpColors to use
    • getHelpColors

      public @NonNull MinecraftHelp.HelpColors getHelpColors()
      Get the colors used for help messages.
      Returns:
      The active MinecraftHelp.HelpColors
    • setHeaderFooterLength

      public void setHeaderFooterLength(int headerFooterLength)
      Set the length of the header/footer of help menus

      Defaults to DEFAULT_HEADER_FOOTER_LENGTH

      Parameters:
      headerFooterLength - The new length
    • setMaxResultsPerPage

      public void setMaxResultsPerPage(int maxResultsPerPage)
      Set the maximum number of help results to display on one page

      Defaults to DEFAULT_MAX_RESULTS_PER_PAGE

      Parameters:
      maxResultsPerPage - The new value
    • queryCommands

      public void queryCommands(@NonNull String rawQuery, @NonNull C recipient)
      Query commands and send the results to the recipient. Will respect permissions.
      Parameters:
      rawQuery - Command query (without leading '/', including optional page number)
      recipient - Recipient