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)
| 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 |
nothing calls this directly
no test coverage detected