Class ArgumentWord

java.lang.Object
net.minestom.server.command.builder.arguments.Argument<String>
net.minestom.server.command.builder.arguments.ArgumentWord

public class ArgumentWord extends Argument<String>
Represents a single word in the command.

You can specify the valid words with from(String...) (do not abuse it or the client will not be able to join).

Example: hey

  • Field Details

  • Constructor Details

    • ArgumentWord

      public ArgumentWord(String id)
  • Method Details

    • from

      @NotNull public @NotNull ArgumentWord from(@Nullable @Nullable String... restrictions)
      Used to force the use of a few precise words instead of complete freedom.

      WARNING: having an array too long would result in a packet too big or the client being stuck during login.

      Parameters:
      restrictions - the accepted words, can be null but if an array is passed you need to ensure that it is filled with non-null values
      Returns:
      'this' for chaining
      Throws:
      NullPointerException - if restrictions is not null but contains null value(s)
    • parse

      @NotNull public @NotNull String parse(@NotNull @NotNull CommandSender sender, @NotNull @NotNull String input) throws ArgumentSyntaxException
      Description copied from class: Argument
      Parses the given input, and throw an ArgumentSyntaxException if the input cannot be converted to T
      Specified by:
      parse in class Argument<String>
      Parameters:
      input - the argument to parse
      Returns:
      the parsed argument
      Throws:
      ArgumentSyntaxException - if value is not valid
    • parser

      public String parser()
      Specified by:
      parser in class Argument<String>
    • nodeProperties

      public byte @Nullable [] nodeProperties()
      Overrides:
      nodeProperties in class Argument<String>
    • hasRestrictions

      public boolean hasRestrictions()
      Gets if this argument allow complete freedom in the word choice or if a list has been defined.
      Returns:
      true if the word selection is restricted
    • getRestrictions

      @Nullable public @Nullable String[] getRestrictions()
      Gets all the word restrictions.
      Returns:
      the word restrictions, can be null
    • toString

      public String toString()
      Overrides:
      toString in class Object