Class PlayerInputSession.Builder

java.lang.Object
me.tayebyassine.homestead.sessions.PlayerInputSession.Builder
Enclosing class:
PlayerInputSession

public static final class PlayerInputSession.Builder extends Object
A builder for constructing PlayerInputSession instances with a fluent API.
  • Method Details

    • callback

      public PlayerInputSession.Builder callback(BiConsumer<org.bukkit.entity.Player, String> callback)
      Set the callback invoked with the player's input.
      Parameters:
      callback - the callback receiving the player and their input
      Returns:
      this builder
    • validator

      public PlayerInputSession.Builder validator(com.google.common.base.Function<String,Boolean> validator)
      Set a validator that filters acceptable input. The session is only forwarded to the callback when this returns true.
      Parameters:
      validator - the input validator
      Returns:
      this builder
    • onCancel

      public PlayerInputSession.Builder onCancel(Consumer<org.bukkit.entity.Player> onCancel)
      Set a callback invoked when the player types "cancel".
      Parameters:
      onCancel - the cancel callback
      Returns:
      this builder
    • prompt

      public PlayerInputSession.Builder prompt(int promptId)
      Set the prompt ID used to look up the display message.
      Parameters:
      promptId - the prompt identifier
      Returns:
      this builder
    • prompt

      public PlayerInputSession.Builder prompt(int promptId, Placeholder promptPlaceholder)
      Set the prompt ID and placeholder values for the display message.
      Parameters:
      promptId - the prompt identifier
      promptPlaceholder - the placeholder values to apply
      Returns:
      this builder
    • timeout

      public PlayerInputSession.Builder timeout(int seconds)
      Set the timeout in seconds before the session is automatically destroyed.
      Parameters:
      seconds - the timeout duration
      Returns:
      this builder
    • build

      public PlayerInputSession build()
      Build the session. A callback must have been set via callback(BiConsumer).
      Returns:
      the new player input session
      Throws:
      IllegalStateException - if no callback was set