Skip to content

Commit

Permalink
move chat input to OnlineUser
Browse files Browse the repository at this point in the history
  • Loading branch information
Snabeldier committed Jan 26, 2025
1 parent abfce26 commit 3aa3104
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
36 changes: 0 additions & 36 deletions src/main/java/minevalley/core/api/messaging/MessageReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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<String> 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<String> 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.
* <p>
* If the receiver is not in a chat input, this method does nothing.
*/
void leaveChatInput();
}
38 changes: 37 additions & 1 deletion src/main/java/minevalley/core/api/users/OnlineUser.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<String> 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<String> 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.
* <p>
* 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.
* <br>
Expand Down

0 comments on commit 3aa3104

Please sign in to comment.