Class ChatInputAPI

java.lang.Object
io.github.lucfr1746.llibrary.chatinput.ChatInputAPI

public class ChatInputAPI extends Object
API for handling chat input interactions with players. Allows setting various parameters like flags, allowed commands, messages, and timeouts.
  • 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

      public ChatInputAPI setFlags(@NotNull @NotNull InputFlag... inputFlags)
      Sets input flags.
      Parameters:
      inputFlags - Flags to set.
      Returns:
      The current ChatInputAPI instance for method chaining.
    • setAttempts

      public ChatInputAPI setAttempts(int attempts)
      Sets the maximum number of attempts allowed.
      Parameters:
      attempts - The number of attempts.
      Returns:
      The current ChatInputAPI instance for method chaining.
    • setAllowedCommands

      public ChatInputAPI setAllowedCommands(@NotNull @NotNull List<String> commands)
      Sets allowed commands during input.
      Parameters:
      commands - List of allowed commands.
      Returns:
      The current ChatInputAPI instance for method chaining.
    • setAllowedCommands

      public ChatInputAPI setAllowedCommands(@NotNull @NotNull String... commands)
      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

      public ChatInputAPI setTimeout(int timeout)
      Sets the timeout duration for the chat input.
      Parameters:
      timeout - Timeout in seconds.
      Returns:
      The current ChatInputAPI instance for method chaining.
    • execute

      public void execute(@NotNull @NotNull Consumer<String> onSuccess)
      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.