|
| 1 | +package minevalley.core.api.messaging; |
| 2 | + |
| 3 | +import minevalley.core.api.messaging.clickable.ChatMenu; |
| 4 | +import minevalley.core.api.messaging.clickable.ClickableOption; |
| 5 | +import minevalley.core.api.messaging.instruction.Instruction; |
| 6 | +import minevalley.core.api.messaging.types.MessageType; |
| 7 | +import net.kyori.adventure.text.ComponentLike; |
| 8 | +import org.jetbrains.annotations.Contract; |
| 9 | + |
| 10 | +import javax.annotation.Nonnull; |
| 11 | +import java.util.function.Consumer; |
| 12 | + |
| 13 | +@SuppressWarnings("unused") |
| 14 | +public interface DialogReceiver { |
| 15 | + |
| 16 | + /** |
| 17 | + * Sends a message to the receiver. |
| 18 | + * |
| 19 | + * @param message the message to send |
| 20 | + * @param menu the menu to send |
| 21 | + * @return the menu that was sent |
| 22 | + * @throws IllegalArgumentException if the message or menu is null |
| 23 | + */ |
| 24 | + @Nonnull |
| 25 | + @Contract("_, _ -> new") |
| 26 | + ChatMenu sendMessage(@Nonnull ComponentLike message, @Nonnull ClickableOption... menu) |
| 27 | + throws IllegalArgumentException; |
| 28 | + |
| 29 | + /** |
| 30 | + * Sends a message to the receiver. |
| 31 | + * |
| 32 | + * @param message the message to send |
| 33 | + * @param instruction the instruction to send |
| 34 | + * @param menu the menu to send |
| 35 | + * @return the menu that was sent |
| 36 | + * @throws IllegalArgumentException if the message, instruction or menu is null |
| 37 | + */ |
| 38 | + @Nonnull |
| 39 | + @Contract("_, _, _ -> new") |
| 40 | + ChatMenu sendMessage(@Nonnull ComponentLike message, @Nonnull Instruction instruction, |
| 41 | + @Nonnull ClickableOption... menu) throws IllegalArgumentException; |
| 42 | + |
| 43 | + /** |
| 44 | + * Sends a message to the receiver. |
| 45 | + * |
| 46 | + * @param type the type of message |
| 47 | + * @param message the message to send |
| 48 | + * @param menu the menu to send |
| 49 | + * @return the menu that was sent |
| 50 | + * @throws IllegalArgumentException if the type, message or menu is null |
| 51 | + */ |
| 52 | + @Nonnull |
| 53 | + @Contract("_, _, _ -> new") |
| 54 | + ChatMenu sendMessage(@Nonnull MessageType type, @Nonnull ComponentLike message, @Nonnull ClickableOption... menu) |
| 55 | + throws IllegalArgumentException; |
| 56 | + |
| 57 | + /** |
| 58 | + * Sends a message to the receiver. |
| 59 | + * |
| 60 | + * @param type the type of message |
| 61 | + * @param message the message to send |
| 62 | + * @param instruction the instruction to send |
| 63 | + * @param menu the menu to send |
| 64 | + * @return the menu that was sent |
| 65 | + * @throws IllegalArgumentException if the type, message, instruction or menu is null |
| 66 | + */ |
| 67 | + @Nonnull |
| 68 | + @Contract("_, _, _, _ -> new") |
| 69 | + ChatMenu sendMessage(@Nonnull MessageType type, @Nonnull ComponentLike message, @Nonnull Instruction instruction, |
| 70 | + @Nonnull ClickableOption... menu) throws IllegalArgumentException; |
| 71 | + |
| 72 | + /** |
| 73 | + * Sends a message to the receiver and waits for an input. |
| 74 | + * |
| 75 | + * @param text the text to send |
| 76 | + * @param callback the callback to call when the user inputs something |
| 77 | + * @throws IllegalArgumentException if the text or callback is null |
| 78 | + */ |
| 79 | + void input(@Nonnull String text, @Nonnull Consumer<String> callback) throws IllegalArgumentException; |
| 80 | + |
| 81 | + /** |
| 82 | + * Sends a message to the receiver and waits for an input. |
| 83 | + * |
| 84 | + * @param text the text to send |
| 85 | + * @param instruction the instruction to send |
| 86 | + * @param callback the callback to call when the user inputs something |
| 87 | + * @throws IllegalArgumentException if the text, instruction or callback is null |
| 88 | + */ |
| 89 | + void input(@Nonnull String text, @Nonnull Instruction instruction, @Nonnull Consumer<String> callback) |
| 90 | + throws IllegalArgumentException; |
| 91 | + |
| 92 | + /** |
| 93 | + * Checks if the receiver is currently in a chat input. |
| 94 | + * |
| 95 | + * @return true if the receiver is in a chat input, false otherwise |
| 96 | + */ |
| 97 | + @Contract(pure = true) |
| 98 | + boolean isInChatInput(); |
| 99 | + |
| 100 | + /** |
| 101 | + * Leaves the current chat input. |
| 102 | + * <p> |
| 103 | + * If the receiver is not in a chat input, this method does nothing. |
| 104 | + */ |
| 105 | + void leaveChatInput(); |
| 106 | +} |
0 commit comments