Class PlayerChatEvent
java.lang.Object
net.minestom.server.event.player.PlayerChatEvent
- All Implemented Interfaces:
Event, CancellableEvent, EntityEvent, EntityInstanceEvent, InstanceEvent, PlayerEvent, PlayerInstanceEvent
Called every time a
Player writes and sends something in the chat.
The event can be cancelled to not send anything, and the final message can be changed.-
Constructor Summary
ConstructorsConstructorDescriptionPlayerChatEvent(Player player, Collection<Player> recipients, String rawMessage) -
Method Summary
Modifier and TypeMethodDescriptionGets the final message component that will be sent.Gets the player.Gets the original message content sent by the player.Returns the players who will receive the message.booleanGets if theEventshould be cancelled or not.voidsetCancelled(boolean cancel) Marks theEventas cancelled or not.voidsetFormattedMessage(Component message) Used to change the final message component.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EntityInstanceEvent
getInstanceMethods inherited from interface PlayerEvent
getEntity
-
Constructor Details
-
PlayerChatEvent
-
-
Method Details
-
getRecipients
Returns the players who will receive the message.It can be modified to add and remove recipients.
- Returns:
- a modifiable list of the message's targets
-
getRawMessage
Gets the original message content sent by the player.- Returns:
- the sender's message
-
getFormattedMessage
Gets the final message component that will be sent.- Returns:
- the chat message component
-
setFormattedMessage
Used to change the final message component.- Parameters:
message- the new message component
-
isCancelled
public boolean isCancelled()Description copied from interface:CancellableEventGets if theEventshould be cancelled or not.- Specified by:
isCancelledin interfaceCancellableEvent- Returns:
- true if the event should be cancelled
-
setCancelled
public void setCancelled(boolean cancel) Description copied from interface:CancellableEventMarks theEventas cancelled or not.- Specified by:
setCancelledin interfaceCancellableEvent- Parameters:
cancel- true if the event should be cancelled, false otherwise
-
getPlayer
Description copied from interface:PlayerEventGets the player.- Specified by:
getPlayerin interfacePlayerEvent- Returns:
- the player
-