Class PaperSuggestions

java.lang.Object
io.github.projectunified.craftcommand.paper.PaperSuggestions

public final class PaperSuggestions extends Object
Brigadier suggestion support shared by every generated Paper command wrapper.

Keeping the input handling here means a generated wrapper only states which provider answers for an argument, instead of repeating the argument splitting and filtering for every command.

  • Method Details

    • suggestMatching

      public static CompletableFuture<com.mojang.brigadier.suggestion.Suggestions> suggestMatching(com.mojang.brigadier.context.CommandContext<io.papermc.paper.command.brigadier.CommandSourceStack> ctx, com.mojang.brigadier.suggestion.SuggestionsBuilder builder, Function<String[],Collection<String>> provider)
      Completes the argument the sender is currently typing from a suggestion provider.
      Parameters:
      ctx - the Brigadier command context
      builder - the suggestions builder holding the remaining input
      provider - supplies the candidate suggestions for the parsed arguments
      Returns:
      the suggestions for the current input
    • splitArgs

      public static String[] splitArgs(String input, String rootName)
      Splits raw command input into arguments, dropping the leading command label when present.
      Parameters:
      input - the raw input line
      rootName - the root command name, used to recognise an explicit label
      Returns:
      the command arguments