Class PrefabArgumentType

All Implemented Interfaces:
SuggestionProvider

public class PrefabArgumentType extends SingleArgumentType<String>
Resolves a single prefab by key across all browsable locations (asset packs and the server directory). Suggests every prefab and validates that the key resolves to an existing file. The parsed value is the key as entered, which PrefabStore.findBrowsablePrefabPath(String) re-resolves later.
  • Constructor Details

    • PrefabArgumentType

      public PrefabArgumentType(@Nonnull String name, @Nonnull String argumentUsage)
  • Method Details

    • parse

      @Nullable public String parse(String input, ParseResult parseResult)
      Description copied from class: SingleArgumentType
      Parses the input String and returns a value of Type DataType. If anything goes wrong during parsing, you should use ParseResult.fail(Message, Message...) and then return null
      Specified by:
      parse in class SingleArgumentType<String>
      Parameters:
      input - The argument String from the Tokenizer
      parseResult - The parseResult to fail if anything goes wrong
      Returns:
      the converted value
    • suggest

      public void suggest(@Nonnull CommandSender sender, @Nonnull String textAlreadyEntered, int numParametersTyped, @Nonnull SuggestionResult result)
      Description copied from class: ArgumentType
      Override this method to provide ArgumentType-specific suggestions that don't rely on the context of the command. Use SuggestionResult.suggest(Object) or any other "suggest" methods of SuggestionResult to provide the suggestions.
      Specified by:
      suggest in interface SuggestionProvider
      Overrides:
      suggest in class ArgumentType<String>
      Parameters:
      sender - The sender who sent the command
      textAlreadyEntered - The text already entered for this command
      numParametersTyped - The number of parameters that have been typed, in relation to ArgumentType.numberOfParameters
      result - The result of the suggestions, append suggestions to this in order to provide them