Package net.minestom.server.event.player
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
ConstructorDescriptionPlayerChatEvent
(@NotNull Player player, @NotNull Collection<Player> recipients, @NotNull String rawMessage) -
Method Summary
Modifier and TypeMethodDescriptionGets the final message component that will be sent.@NotNull Player
Gets the player.@NotNull String
Gets the original message content sent by the player.@NotNull Collection
<Player> Returns the players who will receive the message.boolean
Gets if theEvent
should be cancelled or not.void
setCancelled
(boolean cancel) Marks theEvent
as cancelled or not.void
setFormattedMessage
(@NotNull Component message) Used to change the final message component.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minestom.server.event.trait.EntityInstanceEvent
getInstance
Methods inherited from interface net.minestom.server.event.trait.PlayerEvent
getEntity
-
Constructor Details
-
PlayerChatEvent
public PlayerChatEvent(@NotNull @NotNull Player player, @NotNull @NotNull Collection<Player> recipients, @NotNull @NotNull String rawMessage)
-
-
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:CancellableEvent
Gets if theEvent
should be cancelled or not.- Specified by:
isCancelled
in interfaceCancellableEvent
- Returns:
- true if the event should be cancelled
-
setCancelled
public void setCancelled(boolean cancel) Description copied from interface:CancellableEvent
Marks theEvent
as cancelled or not.- Specified by:
setCancelled
in interfaceCancellableEvent
- Parameters:
cancel
- true if the event should be cancelled, false otherwise
-
getPlayer
Description copied from interface:PlayerEvent
Gets the player.- Specified by:
getPlayer
in interfacePlayerEvent
- Returns:
- the player
-