Class MinecraftHelp<C>
java.lang.Object
cloud.commandframework.minecraft.extras.MinecraftHelp<C>
- Type Parameters:
C- Command sender type
Opinionated extension of
CommandHelpHandler for Minecraft-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classClass for holding theTextColorsused for help menusstatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final MinecraftHelp.HelpColorsThe default color scheme forMinecraftHelpstatic final intstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
ConstructorsConstructorDescriptionMinecraftHelp(@NonNull String commandPrefix, @NonNull AudienceProvider<C> audienceProvider, @NonNull cloud.commandframework.CommandManager<C> commandManager) Construct a new Minecraft help instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidcommandFilter(@NonNull Predicate<cloud.commandframework.Command<C>> commandPredicate) Sets a filter for what commands are visible inside the help menu.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 anAudience.voiddescriptionDecorator(@NonNull BiFunction<@NonNull C, @NonNull String, @NonNull net.kyori.adventure.text.Component> decorator) Set the description decorator which will turn command and argument description strings into components.voiddescriptionDecorator(@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.@NonNull net.kyori.adventure.audience.AudiencegetAudience(@NonNull C sender) Map a command sender to anAudience@NonNull AudienceProvider<C>Get the audience provider that was used to create this instance@NonNull cloud.commandframework.CommandManager<C>Get the command manager instance@NonNull MinecraftHelp.HelpColorsGet the colors used for help messages.voidmessageProvider(@NonNull MinecraftHelp.MessageProvider<C> messageProvider) Set a custom message provider function to be used for getting messages from keys.voidqueryCommands(@NonNull String rawQuery, @NonNull C recipient) Query commands and send the results to the recipient.voidsetHeaderFooterLength(int headerFooterLength) Set the length of the header/footer of help menusvoidsetHelpColors(@NonNull MinecraftHelp.HelpColors colors) Set the colors to use for help messages.voidsetMaxResultsPerPage(int maxResultsPerPage) Set the maximum number of help results to display on one pagevoidsetMessage(@NonNull String key, @NonNull String value) Configure a messagevoidsetMessageProvider(@NonNull BiFunction<C, String, String> messageProvider) Set a custom message provider function to be used for getting messages from keys.
-
Field Details
-
DEFAULT_HEADER_FOOTER_LENGTH
public static final int DEFAULT_HEADER_FOOTER_LENGTH- See Also:
-
DEFAULT_MAX_RESULTS_PER_PAGE
public static final int DEFAULT_MAX_RESULTS_PER_PAGE- See Also:
-
DEFAULT_HELP_COLORS
The default color scheme forMinecraftHelp -
MESSAGE_HELP_TITLE
- See Also:
-
MESSAGE_COMMAND
- See Also:
-
MESSAGE_DESCRIPTION
- See Also:
-
MESSAGE_NO_DESCRIPTION
- See Also:
-
MESSAGE_ARGUMENTS
- See Also:
-
MESSAGE_OPTIONAL
- See Also:
-
MESSAGE_SHOWING_RESULTS_FOR_QUERY
- See Also:
-
MESSAGE_NO_RESULTS_FOR_QUERY
- See Also:
-
MESSAGE_AVAILABLE_COMMANDS
- See Also:
-
MESSAGE_CLICK_TO_SHOW_HELP
- See Also:
-
MESSAGE_PAGE_OUT_OF_RANGE
- See Also:
-
MESSAGE_CLICK_FOR_NEXT_PAGE
- See Also:
-
MESSAGE_CLICK_FOR_PREVIOUS_PAGE
- See Also:
-
-
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 generationaudienceProvider- Provider that maps the command sender type toAudiencecommandManager- 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 anAudience.- Type Parameters:
C- sender type extendingAudience- Parameters:
commandPrefix- Command that was used to trigger the help menu. Used to help insertion generationcommandManager- command manager- Returns:
- new MinecraftHelp instance
- Since:
- 1.5.0
-
getCommandManager
Get the command manager instance- Returns:
- Command manager
-
getAudienceProvider
Get the audience provider that was used to create this instance- Returns:
- Audience provider
-
getAudience
Map a command sender to anAudience- Parameters:
sender- Sender to map- Returns:
- Mapped audience
-
commandFilter
Sets a filter for what commands are visible inside the help menu. When thePredicateteststrue, 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
-
descriptionDecorator
public void descriptionDecorator(@NonNull BiFunction<@NonNull C, @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.7.0
-
setMessage
Configure a message- Parameters:
key- Message key. These are constants inMinecraftHelpvalue- The text for the message
-
setMessageProvider
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
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.MessageProviderwill have priority over a message provider registered throughsetMessageProvider(BiFunction)- Parameters:
messageProvider- The message provider to use- Since:
- 1.4.0
-
setHelpColors
Set the colors to use for help messages.- Parameters:
colors- The newMinecraftHelp.HelpColorsto use
-
getHelpColors
Get the colors used for help messages.- Returns:
- The active
MinecraftHelp.HelpColors
-
setMaxResultsPerPage
public void setMaxResultsPerPage(int maxResultsPerPage) Set the maximum number of help results to display on one pageDefaults to
DEFAULT_MAX_RESULTS_PER_PAGE- Parameters:
maxResultsPerPage- The new value
-
queryCommands
Query commands and send the results to the recipient. Will respect permissions.- Parameters:
rawQuery- Command query (without leading '/', including optional page number)recipient- Recipient
-