Class SuggestionsBranch

java.lang.Object
dev.jorel.commandapi.arguments.SuggestionsBranch

public class SuggestionsBranch extends Object
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 Details

    • suggest

      public static SuggestionsBranch suggest(ArgumentSuggestions... suggestions)
      Creates a SuggestionsBranch starting with the given suggestions. If a suggestions is null, the suggestions at that position will not be overridden.
      Parameters:
      suggestions - An array of ArgumentSuggestions representing the suggestions. Use the static methods in ArgumentSuggestions to create these.
      Returns:
      a new SuggestionsBranch starting with the given suggestions
    • branch

      public SuggestionsBranch branch(SuggestionsBranch... branches)
      Adds further branches to this SuggestionsBranch. After going through the suggestions provided by suggest(ArgumentSuggestions...) the suggestions of these branches will be used.
      Parameters:
      branches - An array of SuggestionsBranch representing the branching suggestions. Use suggest(ArgumentSuggestions...) to start creating these.
      Returns:
      the current SuggestionsBranch
    • getNextSuggestion

      public ArgumentSuggestions getNextSuggestion(org.bukkit.command.CommandSender sender, String... previousArguments) throws com.mojang.brigadier.exceptions.CommandSyntaxException
      Gets the next ArgumentSuggestions based on the previous arguments.
      Parameters:
      sender - The CommandSender the suggestions are being built for
      previousArguments - An array of previously given arguments that is used to find the next ArgumentSuggestions
      Returns:
      The next ArgumentSuggestions given by this SuggestionsBranch or 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 this SuggestionsBranch
    • enforceReplacements

      public void enforceReplacements(org.bukkit.command.CommandSender sender, String... arguments) throws com.mojang.brigadier.exceptions.CommandSyntaxException
      Makes sure the given arguments correspond to the suggestions of this SuggestionsBranch
      Parameters:
      sender - The CommandSender the suggestions are being built for
      arguments - An array of arguments to check against the suggestions of this SuggestionsBranch
      Throws:
      com.mojang.brigadier.exceptions.CommandSyntaxException - if the given arguments don't lead to a valid path for this SuggestionsBranch