Class ChatInputAPI
java.lang.Object
io.github.lucfr1746.llibrary.chatinput.ChatInputAPI
API for handling chat input interactions with players.
Allows setting various parameters like flags, allowed commands, messages, and timeouts.
-
Constructor Summary
ConstructorsConstructorDescriptionChatInputAPI
(org.bukkit.plugin.java.JavaPlugin plugin, org.bukkit.entity.Player player, ChatInput inputType) Constructs a new ChatInputAPI instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic ChatInputAPI
create
(org.bukkit.plugin.java.JavaPlugin plugin, org.bukkit.entity.Player player, ChatInput inputType) Creates a new instance of ChatInputAPI.void
Executes the chat input prompt and processes the response.void
execute
(@NotNull Consumer<String> onSuccess, @NotNull Consumer<InputStatus> onFailure) Executes the chat input prompt and provides callbacks for both success and failure cases.setAllowedCommands
(@NotNull String... commands) Sets allowed commands during input.setAllowedCommands
(@NotNull List<String> commands) Sets allowed commands during input.setAttempts
(int attempts) Sets the maximum number of attempts allowed.Sets input flags.setMessage
(@NotNull InputMessage inputMessage, @NotNull String message) Sets a custom message for the chat input prompt.setTimeout
(int timeout) Sets the timeout duration for the chat input.
-
Constructor Details
-
ChatInputAPI
public ChatInputAPI(org.bukkit.plugin.java.JavaPlugin plugin, org.bukkit.entity.Player player, ChatInput inputType) Constructs a new ChatInputAPI instance.- Parameters:
plugin
- The plugin instance.player
- The player who will provide input.inputType
- The type of chat input to handle.- Throws:
NullPointerException
- if any parameter is null.
-
-
Method Details
-
create
public static ChatInputAPI create(org.bukkit.plugin.java.JavaPlugin plugin, org.bukkit.entity.Player player, ChatInput inputType) Creates a new instance of ChatInputAPI.- Parameters:
plugin
- The plugin instance.player
- The player who will provide input.inputType
- The type of chat input to handle.- Returns:
- A new ChatInputAPI instance.
-
setFlags
Sets input flags.- Parameters:
inputFlags
- Flags to set.- Returns:
- The current ChatInputAPI instance for method chaining.
-
setAttempts
Sets the maximum number of attempts allowed.- Parameters:
attempts
- The number of attempts.- Returns:
- The current ChatInputAPI instance for method chaining.
-
setAllowedCommands
Sets allowed commands during input.- Parameters:
commands
- List of allowed commands.- Returns:
- The current ChatInputAPI instance for method chaining.
-
setAllowedCommands
Sets allowed commands during input.- Parameters:
commands
- Array of allowed commands.- Returns:
- The current ChatInputAPI instance for method chaining.
-
setMessage
public ChatInputAPI setMessage(@NotNull @NotNull InputMessage inputMessage, @NotNull @NotNull String message) Sets a custom message for the chat input prompt.- Parameters:
inputMessage
- The type of message to set.message
- The message text.- Returns:
- The current ChatInputAPI instance for method chaining.
-
setTimeout
Sets the timeout duration for the chat input.- Parameters:
timeout
- Timeout in seconds.- Returns:
- The current ChatInputAPI instance for method chaining.
-
execute
Executes the chat input prompt and processes the response.- Parameters:
onSuccess
- Callback function to handle successful input.
-
execute
public void execute(@NotNull @NotNull Consumer<String> onSuccess, @NotNull @NotNull Consumer<InputStatus> onFailure) Executes the chat input prompt and provides callbacks for both success and failure cases.- Parameters:
onSuccess
- Callback function to handle successful input.onFailure
- Callback function to handle input failures.
-