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
Modifier and TypeClassDescriptionstatic class
Class for holding theTextColors
used for help menusstatic interface
-
Field Summary
Modifier and TypeFieldDescriptionstatic int
static MinecraftHelp.HelpColors
The default color scheme forMinecraftHelp
static int
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
static String
-
Constructor Summary
ConstructorDescriptionMinecraftHelp(@NonNull String commandPrefix, @NonNull AudienceProvider<C> audienceProvider, @NonNull cloud.commandframework.CommandManager<C> commandManager)
Construct a new Minecraft help instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
commandFilter(@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
.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.@NonNull net.kyori.adventure.audience.Audience
getAudience(@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.HelpColors
Get the colors used for help messages.void
messageProvider(@NonNull MinecraftHelp.MessageProvider<C> messageProvider)
Set a custom message provider function to be used for getting messages from keys.void
queryCommands(@NonNull String rawQuery, @NonNull C recipient)
Query commands and send the results to the recipient.void
setHeaderFooterLength(int headerFooterLength)
Set the length of the header/footer of help menusvoid
setHelpColors(@NonNull MinecraftHelp.HelpColors colors)
Set the colors to use for help messages.void
setMaxResultsPerPage(int maxResultsPerPage)
Set the maximum number of help results to display on one pagevoid
setMessage(@NonNull String key, @NonNull String value)
Configure a messagevoid
setMessageProvider(@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:
- Constant Field Values
-
DEFAULT_MAX_RESULTS_PER_PAGE
public static final int DEFAULT_MAX_RESULTS_PER_PAGE- See Also:
- Constant Field Values
-
DEFAULT_HELP_COLORS
The default color scheme forMinecraftHelp
-
MESSAGE_HELP_TITLE
- See Also:
- Constant Field Values
-
MESSAGE_COMMAND
- See Also:
- Constant Field Values
-
MESSAGE_DESCRIPTION
- See Also:
- Constant Field Values
-
MESSAGE_NO_DESCRIPTION
- See Also:
- Constant Field Values
-
MESSAGE_ARGUMENTS
- See Also:
- Constant Field Values
-
MESSAGE_OPTIONAL
- See Also:
- Constant Field Values
-
MESSAGE_SHOWING_RESULTS_FOR_QUERY
- See Also:
- Constant Field Values
-
MESSAGE_NO_RESULTS_FOR_QUERY
- See Also:
- Constant Field Values
-
MESSAGE_AVAILABLE_COMMANDS
- See Also:
- Constant Field Values
-
MESSAGE_CLICK_TO_SHOW_HELP
- See Also:
- Constant Field Values
-
MESSAGE_PAGE_OUT_OF_RANGE
- See Also:
- Constant Field Values
-
MESSAGE_CLICK_FOR_NEXT_PAGE
- See Also:
- Constant Field Values
-
MESSAGE_CLICK_FOR_PREVIOUS_PAGE
- See Also:
- Constant Field Values
-
-
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 toAudience
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 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 thePredicate
teststrue
, 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
Configure a message- Parameters:
key
- Message key. These are constants inMinecraftHelp
value
- 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.MessageProvider
will 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.HelpColors
to 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
-