Class PlayerInputSession.Builder
java.lang.Object
me.tayebyassine.homestead.sessions.PlayerInputSession.Builder
- Enclosing class:
PlayerInputSession
A builder for constructing
PlayerInputSession instances with
a fluent API.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the session.callback(BiConsumer<org.bukkit.entity.Player, String> callback) Set the callback invoked with the player's input.Set a callback invoked when the player types "cancel".prompt(int promptId) Set the prompt ID used to look up the display message.prompt(int promptId, Placeholder promptPlaceholder) Set the prompt ID and placeholder values for the display message.timeout(int seconds) Set the timeout in seconds before the session is automatically destroyed.Set a validator that filters acceptable input.
-
Method Details
-
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 returnstrue.- Parameters:
validator- the input validator- Returns:
- this builder
-
onCancel
Set a callback invoked when the player types "cancel".- Parameters:
onCancel- the cancel callback- Returns:
- this builder
-
prompt
Set the prompt ID used to look up the display message.- Parameters:
promptId- the prompt identifier- Returns:
- this builder
-
prompt
Set the prompt ID and placeholder values for the display message.- Parameters:
promptId- the prompt identifierpromptPlaceholder- the placeholder values to apply- Returns:
- this builder
-
timeout
Set the timeout in seconds before the session is automatically destroyed.- Parameters:
seconds- the timeout duration- Returns:
- this builder
-
build
Build the session. A callback must have been set viacallback(BiConsumer).- Returns:
- the new player input session
- Throws:
IllegalStateException- if no callback was set
-