java.lang.Object
io.github.lucfr1746.llibrary.chatinput.input.ChatInput
Direct Known Subclasses:
DoubleInput, IntegerInput, StringCollectionInput, StringInput

public abstract class ChatInput extends Object
An abstract class that stands as base for all types of inputs.
  • Constructor Details

    • ChatInput

      public ChatInput()
  • Method Details

    • isValidInput

      public abstract boolean isValidInput(@NotNull @NotNull String input)
      Checks if the given input is valid.
      Parameters:
      input - the input
    • sendMessage

      public final void sendMessage(@NotNull @NotNull InputMessage type, @NotNull @NotNull org.bukkit.entity.Player player)
      Sends, if present, the message of the given type to the player. The following placeholders can be used: {player}, {attempts}
      Parameters:
      type - the message type
      player - the player
    • sendMessage

      public final void sendMessage(@NotNull @NotNull InputMessage type, @NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String input)
      Sends, if present, the message of the given type to the player. The following placeholders can be used: {player}, {attempts}, {input}
      Parameters:
      type - the message type
      player - the player
      input - the input
    • setMessage

      @NotNull public final @NotNull ChatInput setMessage(@NotNull @NotNull InputMessage type, @NotNull @NotNull String message)
      Sets the message for the given message type.
      Parameters:
      type - the message type
      message - the message
    • hasFlag

      public final boolean hasFlag(@NotNull @NotNull InputFlag flag)
      Checks if the given flag is enabled.
      Parameters:
      flag - the flag
      Returns:
      whether the flag is or not enabled
    • setFlags

      @NotNull public final @NotNull ChatInput setFlags(@NotNull @NotNull InputFlag... flags)
      Sets the given flags as enabled.
      Parameters:
      flags - the flags
    • isCommandAllowed

      public final boolean isCommandAllowed(@NotNull @NotNull String command)
      Checks if the given command is allowed to be used.
      Parameters:
      command - the command
      Returns:
      whether the command is allowed or not
    • setAllowedCommands

      @NotNull public final @NotNull ChatInput setAllowedCommands(@NotNull @NotNull List<String> allowedCommands)
      Sets the allowed commands to be used.
      Parameters:
      allowedCommands - the commands
    • setAllowedCommands

      @NotNull public final @NotNull ChatInput setAllowedCommands(@NotNull @NotNull String... allowedCommands)
      Sets the allowed commands to be used.
      Parameters:
      allowedCommands - the commands
    • getAttempts

      public final int getAttempts()
      Gets the remaining number of attempts the input can be given.
      Returns:
      the remaining number of attempts
    • setAttempts

      @NotNull public final @NotNull ChatInput setAttempts(int attempts)
      Sets the remaining number of attempts the input can be given. Any value smaller than 0 will be interpreted as infinite.
      Parameters:
      attempts - the number of attempts
    • getTimeout

      public final int getTimeout()
      Gets the duration after which the input prompt will be canceled. This duration is in seconds. Any value smaller than 0 will disable the timeout.
      Returns:
      the duration
    • setTimeout

      @NotNull public final @NotNull ChatInput setTimeout(int timeout)
      Gets the duration after which the input prompt will be canceled. This duration is in seconds. Any value smaller than 0 will disable the timeout.
      Parameters:
      timeout - the duration
    • copyTo

      public final void copyTo(@NotNull @NotNull ChatInput input)
      Copies the properties of this object in the given object.
      Parameters:
      input - the object