MCPcopy Create free account
hub / github.com/boxbeam/RedLib / prompt

Method prompt

src/redempt/redlib/misc/ChatPrompt.java:34–44  ·  view source on GitHub ↗

Prompts a player with callbacks for player response and cancelling @param player The player to prompt @param prompt The prompt to send to the player, or null for no prompt @param showCancelMessage Whether to show the cancel message to the player @param onResponse The ca

(Player player, String prompt, boolean showCancelMessage, Consumer<String> onResponse, Consumer<CancelReason> onCancel)

Source from the content-addressed store, hash-verified

32 * @param onCancel The callback for when the prompt is cancelled
33 */
34 public static void prompt(Player player, String prompt, boolean showCancelMessage, Consumer<String> onResponse, Consumer<CancelReason> onCancel) {
35 Prompt removed = prompts.remove(player);
36 if (removed != null) {
37 removed.cancel(CancelReason.PROMPT_OVERRIDDEN);
38 }
39 prompts.put(player, new Prompt(onResponse, onCancel));
40 Optional.ofNullable(prompt).ifPresent(player::sendMessage);
41 if (showCancelMessage) {
42 player.sendMessage(RedLib.msg("cancelPromptMessage").replace("%canceltext%", RedLib.msg("cancelText")));
43 }
44 }
45
46 /**
47 * Prompts a player with callbacks for player response and cancelling

Callers

nothing calls this directly

Calls 4

cancelMethod · 0.95
msgMethod · 0.95
sendMessageMethod · 0.80
removeMethod · 0.65

Tested by

no test coverage detected