Class ChatInput
java.lang.Object
io.github.lucfr1746.llibrary.chatinput.input.ChatInput
- Direct Known Subclasses:
DoubleInput
,IntegerInput
,StringCollectionInput
,StringInput
An abstract class that stands as base for all types of inputs.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal void
Copies the properties of this object in the given object.final int
Gets the remaining number of attempts the input can be given.final int
Gets the duration after which the input prompt will be canceled.final boolean
Checks if the given flag is enabled.final boolean
isCommandAllowed
(@NotNull String command) Checks if the given command is allowed to be used.abstract boolean
isValidInput
(@NotNull String input) Checks if the given input is valid.final void
sendMessage
(@NotNull InputMessage type, @NotNull org.bukkit.entity.Player player) Sends, if present, the message of the given type to the player.final void
sendMessage
(@NotNull InputMessage type, @NotNull org.bukkit.entity.Player player, @NotNull String input) Sends, if present, the message of the given type to the player.final @NotNull ChatInput
setAllowedCommands
(@NotNull String... allowedCommands) Sets the allowed commands to be used.final @NotNull ChatInput
setAllowedCommands
(@NotNull List<String> allowedCommands) Sets the allowed commands to be used.final @NotNull ChatInput
setAttempts
(int attempts) Sets the remaining number of attempts the input can be given.final @NotNull ChatInput
Sets the given flags as enabled.final @NotNull ChatInput
setMessage
(@NotNull InputMessage type, @NotNull String message) Sets the message for the given message type.final @NotNull ChatInput
setTimeout
(int timeout) Gets the duration after which the input prompt will be canceled.
-
Constructor Details
-
ChatInput
public ChatInput()
-
-
Method Details
-
isValidInput
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 typeplayer
- 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 typeplayer
- the playerinput
- 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 typemessage
- the message
-
hasFlag
Checks if the given flag is enabled.- Parameters:
flag
- the flag- Returns:
- whether the flag is or not enabled
-
setFlags
Sets the given flags as enabled.- Parameters:
flags
- the flags
-
isCommandAllowed
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
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
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
Copies the properties of this object in the given object.- Parameters:
input
- the object
-