Class MinecraftHelp<C>
java.lang.Object
org.incendo.cloud.minecraft.extras.MinecraftHelp<C>
- Type Parameters:
C- command sender type
- Direct Known Subclasses:
ImmutableMinecraftHelp
Opinionated extension of
HelpRenderer for Minecraft.
This class should not be extended, and the only implementation of it is ImmutableMinecraftHelp.
You may customize certain aspects of the help menu by using the builder.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfaceClass 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 -
Method Summary
Modifier and TypeMethodDescriptionMaps a command sender to anAudienceabstract @NonNull AudienceProvider<C> Returns the audience provider that was used to create this instance.static <C> @NonNull ImmutableMinecraftHelp.CommandManagerBuildStage<C> builder()Returns a newMinecraftHelpbuilder.static <C> MinecraftHelp.MessageProvider<C> captionMessageProvider(CaptionRegistry<C> registry, ComponentCaptionFormatter<C> formatter) Creates aMinecraftHelp.MessageProviderthat delegates to the providedCaptionRegistryandComponentCaptionFormatter.colors()Returns the colors used for help messages.Returns the filter that determines what commands are visible inside the help menu.abstract @NonNull CommandManager<C> Returns the command manager instance.Returns the command prefix.static <C> @NonNull MinecraftHelp<C> create(@NonNull String commandPrefix, @NonNull CommandManager<C> commandManager, @NonNull AudienceProvider<C> audienceProvider) Constructs a new Minecraft help instance using the default values.static <C extends Audience>
@NonNull MinecraftHelp<C> createNative(@NonNull String commandPrefix, @NonNull CommandManager<C> commandManager) Constructs a new Minecraft help instance for a sender type which is anAudience.static <C> CaptionProvider<C> Returns aCaptionProviderfor the default messages.Returns the description decorator which turns descriptions into components.@org.checkerframework.checker.index.qual.NonNegative intReturns the length of the header/footer of help menus.static @NonNull MinecraftHelp.HelpColorshelpColors(@NonNull TextColor primary, @NonNull TextColor highlight, @NonNull TextColor alternateHighlight, @NonNull TextColor text, @NonNull TextColor accent) Creates a newMinecraftHelp.HelpColorsinstance.Returns the help handler.@org.checkerframework.checker.index.qual.NonNegative intReturns the maximum number of help results to display on a page.Returns the message provider which is used to retrieve messages from message keys.messages()Returns the messages which are used by the defaultMinecraftHelp.MessageProvider.voidqueryCommands(@NonNull String rawQuery, @NonNull C recipient) Queries commands and send the results to the recipient.
-
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:
-
-
Method Details
-
defaultCaptionsProvider
Returns aCaptionProviderfor the default messages.- Type Parameters:
C- command sender type- Returns:
- default captions provider
- See Also:
-
createNative
@API(status=STABLE, since="1.5.0") public static <C extends Audience> @NonNull MinecraftHelp<C> createNative(@NonNull String commandPrefix, @NonNull CommandManager<C> commandManager) Constructs 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
-
create
@API(status=STABLE, since="2.0.0") public static <C> @NonNull MinecraftHelp<C> create(@NonNull String commandPrefix, @NonNull CommandManager<C> commandManager, @NonNull AudienceProvider<C> audienceProvider) Constructs a new Minecraft help instance using the default values.- Type Parameters:
C- sender type extendingAudience- Parameters:
commandPrefix- command that was used to trigger the help menu. Used to help insertion generationcommandManager- command manageraudienceProvider- mapper fromMinecraftHelptoAudience- Returns:
- new MinecraftHelp instance
- Since:
- 2.0.0
-
builder
@API(status=STABLE, since="2.0.0") public static <C> @NonNull ImmutableMinecraftHelp.CommandManagerBuildStage<C> builder()Returns a newMinecraftHelpbuilder.- Type Parameters:
C- the command sender type- Returns:
- the builder
- Since:
- 2.0.0
-
commandManager
Returns the command manager instance.- Returns:
- command manager
-
audienceProvider
Returns the audience provider that was used to create this instance.- Returns:
- audience provider
-
commandPrefix
Returns the command prefix.- Returns:
- command prefix
- Since:
- 2.0.0
-
helpHandler
Returns the help handler.- Returns:
- the help handler
- Since:
- 2.0.0
-
audience
Maps a command sender to anAudience- Parameters:
sender- Sender to map- Returns:
- Mapped audience
-
commandFilter
Returns the filter that determines what commands are visible inside the help menu.The default filter is
CommandPredicate.acceptAll().- Returns:
- the filter
- Since:
- 2.0.0
-
descriptionDecorator
@Default @API(status=STABLE, since="2.0.0") public @NonNull MinecraftHelp.DescriptionDecorator<C> descriptionDecorator()Returns the description decorator which turns descriptions into components.The default decorator is
MinecraftHelp.DescriptionDecorator.text().- Returns:
- the decorator
- Since:
- 2.0.0
-
messages
@API(status=STABLE, since="2.0.0") public abstract @NonNull Map<@NonNull String,@NonNull String> messages()Returns the messages which are used by the defaultMinecraftHelp.MessageProvider.Placeholders in the format <name> will be replaced.
- Returns:
- the messages
- Since:
- 2.0.0
-
messageProvider
@Default @API(status=STABLE, since="2.0.0") public @NonNull MinecraftHelp.MessageProvider<C> messageProvider()Returns the message provider which is used to retrieve messages from message keys.The keys are constants in
MinecraftHelp.- Returns:
- the message provider
- Since:
- 2.0.0
-
colors
Returns the colors used for help messages.Defaults to
DEFAULT_HELP_COLORS.- Returns:
- the active
MinecraftHelp.HelpColors - Since:
- 2.0.0
-
maxResultsPerPage
@Default @API(status=STABLE, since="2.0.0") public @org.checkerframework.checker.index.qual.NonNegative int maxResultsPerPage()Returns the maximum number of help results to display on a page.Defaults to
DEFAULT_MAX_RESULTS_PER_PAGE.- Returns:
- the maximum number of results
- Since:
- 2.0.0
-
messageOrDefault
-
queryCommands
Queries commands and send the results to the recipient. Will respect permissions.- Parameters:
rawQuery- command query (without leading '/', including optional page number)recipient- recipient
-
captionMessageProvider
public static <C> MinecraftHelp.MessageProvider<C> captionMessageProvider(CaptionRegistry<C> registry, ComponentCaptionFormatter<C> formatter) Creates aMinecraftHelp.MessageProviderthat delegates to the providedCaptionRegistryandComponentCaptionFormatter. Transforms message keys intocaptionsusingCaption.of(String)and the prefixhelp.minecraft..- Type Parameters:
C- command sender type- Parameters:
registry- caption registryformatter- caption formatter- Returns:
- message provider
- See Also:
-
helpColors
public static @NonNull MinecraftHelp.HelpColors helpColors(@NonNull TextColor primary, @NonNull TextColor highlight, @NonNull TextColor alternateHighlight, @NonNull TextColor text, @NonNull TextColor accent) Creates a newMinecraftHelp.HelpColorsinstance.- Parameters:
primary- the primary color for the color schemehighlight- the primary color used to highlight commands and queriesalternateHighlight- the secondary color used to highlight commands and queriestext- the color used for description textaccent- the color used for accents and symbols- Returns:
- a new
MinecraftHelp.HelpColorsinstance
-