Package dev.oumaimaa.kawaiiapi.input
Class ChatInput
java.lang.Object
dev.oumaimaa.kawaiiapi.input.ChatInput
Modern chat input system using AsyncChatEvent instead of deprecated Conversation API.
Provides type-safe input validation with support for text, numeric, boolean, and option-based inputs.
This system automatically handles:
- Input cancellation via configurable escape words
- Automatic timeout and cleanup
- Player disconnect handling
- Type-specific validation
- Version:
- 1.0
- Author:
- KawaiiDevelopment
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancancelInput(@NotNull org.bukkit.entity.Player player) Cancels any active input session for the specified player.static booleanhasActiveSession(@NotNull org.bukkit.entity.Player player) Checks if a player has an active input session.static voidrequestBooleanInput(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull org.bukkit.entity.Player player, @NotNull String prompt, @NotNull Consumer<Boolean> onInput) Requests boolean input (yes/no) from a player.static voidrequestInput(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull org.bukkit.entity.Player player, @NotNull String prompt, @NotNull Consumer<String> onInput) Requests simple text input without validation.static voidrequestInput(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull org.bukkit.entity.Player player, @NotNull String prompt, @NotNull Predicate<String> validator, Function<String, String> errorMessage, @NotNull Consumer<String> onInput, @Nullable Runnable onCancel) Requests text input from a player with custom validation.static voidrequestIntegerInput(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull org.bukkit.entity.Player player, @NotNull String prompt, @NotNull Consumer<Integer> onInput) Requests integer input from a player.static voidrequestNumericInput(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull org.bukkit.entity.Player player, @NotNull String prompt, @NotNull Consumer<Double> onInput) Requests a double/decimal input from a player.static voidrequestOptionInput(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull org.bukkit.entity.Player player, @NotNull String prompt, @NotNull String[] options, @NotNull Consumer<String> onInput) Requests input that must match one of the provided options.static voidrequestRangedIntegerInput(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull org.bukkit.entity.Player player, @NotNull String prompt, int min, int max, @NotNull Consumer<Integer> onInput) Requests an integer within a specific range.
-
Constructor Details
-
ChatInput
public ChatInput()
-
-
Method Details
-
requestInput
public static void requestInput(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String prompt, @NotNull @NotNull Predicate<String> validator, @NotNull Function<String, String> errorMessage, @NotNull @NotNull Consumer<String> onInput, @Nullable @Nullable Runnable onCancel) Requests text input from a player with custom validation.- Parameters:
plugin- The plugin instanceplayer- The player to request input fromprompt- The prompt message to displayvalidator- Function to validate input (return true if valid)errorMessage- Function to generate error message for invalid inputonInput- Callback invoked with valid inputonCancel- Callback invoked on cancellation (can be null)
-
requestInput
public static void requestInput(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String prompt, @NotNull @NotNull Consumer<String> onInput) Requests simple text input without validation.- Parameters:
plugin- The plugin instanceplayer- The player to request input fromprompt- The prompt messageonInput- Callback for the input
-
requestIntegerInput
public static void requestIntegerInput(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String prompt, @NotNull @NotNull Consumer<Integer> onInput) Requests integer input from a player.- Parameters:
plugin- The plugin instanceplayer- The player to request input fromprompt- The prompt messageonInput- Callback with the parsed integer
-
requestNumericInput
public static void requestNumericInput(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String prompt, @NotNull @NotNull Consumer<Double> onInput) Requests a double/decimal input from a player.- Parameters:
plugin- The plugin instanceplayer- The player to request input fromprompt- The prompt messageonInput- Callback with the parsed double
-
requestRangedIntegerInput
public static void requestRangedIntegerInput(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String prompt, int min, int max, @NotNull @NotNull Consumer<Integer> onInput) Requests an integer within a specific range.- Parameters:
plugin- The plugin instanceplayer- The player to request input fromprompt- The prompt messagemin- Minimum value (inclusive)max- Maximum value (inclusive)onInput- Callback with the validated integer
-
requestBooleanInput
public static void requestBooleanInput(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String prompt, @NotNull @NotNull Consumer<Boolean> onInput) Requests boolean input (yes/no) from a player.- Parameters:
plugin- The plugin instanceplayer- The player to request input fromprompt- The prompt messageonInput- Callback with the boolean result
-
requestOptionInput
public static void requestOptionInput(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull String prompt, @NotNull @NotNull String[] options, @NotNull @NotNull Consumer<String> onInput) Requests input that must match one of the provided options.- Parameters:
plugin- The plugin instanceplayer- The player to request input fromprompt- The prompt messageoptions- Valid options (case-insensitive)onInput- Callback with the validated input
-
cancelInput
public static boolean cancelInput(@NotNull @NotNull org.bukkit.entity.Player player) Cancels any active input session for the specified player.- Parameters:
player- The player whose session should be cancelled- Returns:
- true if a session was cancelled, false otherwise
-
hasActiveSession
public static boolean hasActiveSession(@NotNull @NotNull org.bukkit.entity.Player player) Checks if a player has an active input session.- Parameters:
player- The player to check- Returns:
- true if the player has an active session
-