From 3aa31045a9e5b548fa7221654624388c687a515b Mon Sep 17 00:00:00 2001 From: Snabeldier <79211348+Snabeldier@users.noreply.github.com> Date: Sun, 26 Jan 2025 02:31:29 +0100 Subject: [PATCH] move chat input to OnlineUser --- .../core/api/messaging/MessageReceiver.java | 36 ------------------ .../minevalley/core/api/users/OnlineUser.java | 38 ++++++++++++++++++- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/main/java/minevalley/core/api/messaging/MessageReceiver.java b/src/main/java/minevalley/core/api/messaging/MessageReceiver.java index 065c9f3..6c4b10f 100644 --- a/src/main/java/minevalley/core/api/messaging/MessageReceiver.java +++ b/src/main/java/minevalley/core/api/messaging/MessageReceiver.java @@ -12,7 +12,6 @@ import javax.annotation.Nonnull; import java.time.Duration; -import java.util.function.Consumer; /** * This interface is meant to simplify and standardize the way messages are sent to players. @@ -195,39 +194,4 @@ ChatMenu sendMessage(@Nonnull MessageType type, @Nonnull ComponentLike message, */ void showTitle(@Nonnull Component title, @Nonnull Component subtitle, @Nonnull Duration fadeIn, @Nonnull Duration stay, @Nonnull Duration fadeOut) throws IllegalArgumentException; - - /** - * Sends a message to the receiver and waits for an input. - * - * @param text the text to send - * @param callback the callback to call when the user inputs something - * @throws IllegalArgumentException if the text or callback is null - */ - void input(@Nonnull String text, @Nonnull Consumer callback) throws IllegalArgumentException; - - /** - * Sends a message to the receiver and waits for an input. - * - * @param text the text to send - * @param instruction the instruction to send - * @param callback the callback to call when the user inputs something - * @throws IllegalArgumentException if the text, instruction or callback is null - */ - void input(@Nonnull String text, @Nonnull Instruction instruction, @Nonnull Consumer callback) - throws IllegalArgumentException; - - /** - * Checks if the receiver is currently in a chat input. - * - * @return true if the receiver is in a chat input, false otherwise - */ - @Contract(pure = true) - boolean isInChatInput(); - - /** - * Leaves the current chat input. - *

- * If the receiver is not in a chat input, this method does nothing. - */ - void leaveChatInput(); } diff --git a/src/main/java/minevalley/core/api/users/OnlineUser.java b/src/main/java/minevalley/core/api/users/OnlineUser.java index e719a4c..cf545b6 100644 --- a/src/main/java/minevalley/core/api/users/OnlineUser.java +++ b/src/main/java/minevalley/core/api/users/OnlineUser.java @@ -1,10 +1,11 @@ package minevalley.core.api.users; -import minevalley.core.api.messaging.MessageReceiver; import minevalley.core.api.economy.AccountUser; import minevalley.core.api.economy.BankAccount; import minevalley.core.api.enums.sounds.AmbientSound; import minevalley.core.api.enums.sounds.Sound; +import minevalley.core.api.messaging.MessageReceiver; +import minevalley.core.api.messaging.instruction.Instruction; import minevalley.core.api.regions.utils.PlayerLocation; import minevalley.core.api.users.enums.Fraction; import minevalley.core.api.users.enums.McVersion; @@ -45,6 +46,41 @@ default void closeInventory() { getPlayer().closeInventory(); } + /** + * Sends a message to the receiver and waits for an input. + * + * @param text the text to send + * @param callback the callback to call when the user inputs something + * @throws IllegalArgumentException if the text or callback is null + */ + void input(@Nonnull String text, @Nonnull Consumer callback) throws IllegalArgumentException; + + /** + * Sends a message to the receiver and waits for an input. + * + * @param text the text to send + * @param instruction the instruction to send + * @param callback the callback to call when the user inputs something + * @throws IllegalArgumentException if the text, instruction or callback is null + */ + void input(@Nonnull String text, @Nonnull Instruction instruction, @Nonnull Consumer callback) + throws IllegalArgumentException; + + /** + * Checks if the receiver is currently in a chat input. + * + * @return true if the receiver is in a chat input, false otherwise + */ + @Contract(pure = true) + boolean isInChatInput(); + + /** + * Leaves the current chat input. + *

+ * If the receiver is not in a chat input, this method does nothing. + */ + void leaveChatInput(); + /** * Gets whether this user is currently logged in via labymod. *