Package dev.jorel.commandapi.arguments
Class SuggestionsBranch<CommandSender>
java.lang.Object
dev.jorel.commandapi.arguments.SuggestionsBranch<CommandSender>
This class represents a branch in the suggestions of an argument. Use
suggest(ArgumentSuggestions...)
to add suggestions, then branch(SuggestionsBranch...) to add more branches.-
Method Summary
Modifier and TypeMethodDescriptionfinal SuggestionsBranch<CommandSender>branch(SuggestionsBranch<CommandSender>... branches) Adds further branches to thisSuggestionsBranch.voidenforceReplacements(CommandSender sender, String... arguments) Makes sure the given arguments correspond to the suggestions of thisSuggestionsBranchgetNextSuggestion(CommandSender sender, String... previousArguments) Gets the nextArgumentSuggestionsbased on the previous arguments.static <CommandSender>
SuggestionsBranch<CommandSender>suggest(ArgumentSuggestions<CommandSender>... suggestions) Creates aSuggestionsBranchstarting with the given suggestions.
-
Method Details
-
suggest
@SafeVarargs public static <CommandSender> SuggestionsBranch<CommandSender> suggest(ArgumentSuggestions<CommandSender>... suggestions) Creates aSuggestionsBranchstarting with the given suggestions. If a suggestions is null, the suggestions at that position will not be overridden.- Parameters:
suggestions- An array ofArgumentSuggestionsrepresenting the suggestions. Use the static methods in ArgumentSuggestions to create these.- Returns:
- a new
SuggestionsBranchstarting with the given suggestions
-
branch
@SafeVarargs public final SuggestionsBranch<CommandSender> branch(SuggestionsBranch<CommandSender>... branches) Adds further branches to thisSuggestionsBranch. After going through the suggestions provided bysuggest(ArgumentSuggestions...)the suggestions of these branches will be used.- Parameters:
branches- An array ofSuggestionsBranchrepresenting the branching suggestions. Usesuggest(ArgumentSuggestions...)to start creating these.- Returns:
- the current
SuggestionsBranch
-
getNextSuggestion
public ArgumentSuggestions<CommandSender> getNextSuggestion(CommandSender sender, String... previousArguments) throws com.mojang.brigadier.exceptions.CommandSyntaxException Gets the nextArgumentSuggestionsbased on the previous arguments.- Parameters:
sender- TheSuggestionsBranchthe suggestions are being built forpreviousArguments- An array of previously given arguments that is used to find the nextArgumentSuggestions- Returns:
- The next
ArgumentSuggestionsgiven by thisSuggestionsBranchor null if the suggestions should not be overridden - Throws:
com.mojang.brigadier.exceptions.CommandSyntaxException- if the given previous arguments don't lead to a valid path for thisSuggestionsBranch
-
enforceReplacements
public void enforceReplacements(CommandSender sender, String... arguments) throws com.mojang.brigadier.exceptions.CommandSyntaxException Makes sure the given arguments correspond to the suggestions of thisSuggestionsBranch- Parameters:
sender- TheSuggestionsBranchthe suggestions are being built forarguments- An array of arguments to check against the suggestions of thisSuggestionsBranch- Throws:
com.mojang.brigadier.exceptions.CommandSyntaxException- if the given arguments don't lead to a valid path for thisSuggestionsBranch
-