sendChatMessage() for online players

This commit is contained in:
Marc Baloup 2023-06-17 10:56:58 +02:00
parent d59ae22970
commit 98d1a21aab

View File

@ -72,18 +72,31 @@ public interface AbstractOnlinePlayer extends AbstractOffPlayer {
*/
/**
* Display the provided message in the players chat, if the chat is activated.
* Display the provided message in the players chat, if SYSTEM messages are activated.
* @param message the message to display.
*/
void sendMessage(Component message);
/**
* Display the provided message in the players chat, if the chat is activated.
* Display the provided message in the players chat, if SYSTEM messages are activated.
* @param message the message to display.
*/
default void sendMessage(ComponentLike message) {
sendMessage(message.asComponent());
}
/**
* Display the provided message in the players chat, if CHAT messages are activated on the client.
* <p>
* This method differs from {@link #sendMessage(ComponentLike)} with the fact that this method sends the message
* only if {@link #canChat()} returns true.
* The message sent to the client is still a SYSTEM messge, due to CHAT messages required to be signed.
* @param message the message to display as CHAT message.
*/
default void sendChatMessage(ComponentLike message) {
if (canChat())
sendMessage(message.asComponent());
}
/**
* Display the provided message in the players chat, if the chat is activated, prepended with the server prefix.