Package net.minestom.server.event.player
Class PlayerChatEvent
java.lang.Object
net.minestom.server.event.Event
net.minestom.server.event.CancellableEvent
net.minestom.server.event.player.PlayerChatEvent
public class PlayerChatEvent extends CancellableEvent
Called every time a
Player
write and send something in the chat.
The event can be cancelled to do not send anything, and the format can be changed.-
Constructor Summary
Constructors Constructor Description PlayerChatEvent(Player sender, java.util.Collection<Player> recipients, java.lang.String message)
-
Method Summary
Modifier and Type Method Description java.util.function.Function<PlayerChatEvent,RichMessage>
getChatFormatFunction()
Used to retrieve the chat format for this message.java.lang.String
getMessage()
Gets the message sent.java.util.Collection<Player>
getRecipients()
Those are the players who will receive the message.Player
getSender()
Gets the message sender.void
setChatFormat(java.util.function.Function<PlayerChatEvent,RichMessage> chatFormat)
Changes the chat format.void
setMessage(java.lang.String message)
Used to change the message.
-
Constructor Details
-
Method Details
-
setChatFormat
public void setChatFormat(@Nullable java.util.function.Function<PlayerChatEvent,RichMessage> chatFormat)Changes the chat format.- Parameters:
chatFormat
- the custom chat format, null to use the default one
-
getSender
Gets the message sender.- Returns:
- the sender
-
getRecipients
Those are the players who will receive the message.It can be modified to add or remove recipient.
- Returns:
- a modifiable list of message targets
-
getMessage
@NotNull public java.lang.String getMessage()Gets the message sent.- Returns:
- the sender's message
-
setMessage
public void setMessage(@NotNull java.lang.String message)Used to change the message.- Parameters:
message
- the new message
-
getChatFormatFunction
Used to retrieve the chat format for this message.If null, the default format will be used.
- Returns:
- the chat format which will be used, null if this is the default one
-