Class ChatUtils
java.lang.Object
tech.guilhermekaua.spigotboot.core.spigot.conversation.ChatUtils
Entry point for temporary server-to-player chat conversations.
ChatUtils.with(player)
.firstPrompt("#ffaa00Enter an amount, &7or type &ccancel")
.timeout(30, TimeUnit.SECONDS)
.onTimeout(p -> p.sendMessage("Timed out."))
.onChat(ctx -> {
if (ctx.getMessage().equalsIgnoreCase("cancel")) { ctx.end(); return; }
// ... handle input; call ctx.end() when done, or leave active to re-prompt
});
Backed by an internal @Component installed when the spigot-boot context becomes ready.
Calling with(Player) before that point throws IllegalStateException.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidonChat(@NotNull org.bukkit.entity.Player player, @NotNull Consumer<ChatContext> callback) Shorthand forwith(player).onChat(callback)with no options.static @NotNull ChatPromptwith(@NotNull org.bukkit.entity.Player player)
-
Method Details
-
with
- Parameters:
player- the player to converse with- Returns:
- a fluent builder for the conversation
- Throws:
IllegalStateException- if the spigot-boot context is not ready yet
-
onChat
public static void onChat(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull Consumer<ChatContext> callback) Shorthand forwith(player).onChat(callback)with no options.- Parameters:
player- the player to converse withcallback- invoked for each captured message
-