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
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
ConstructorDescriptionPlayerChatEvent
(@NotNull Player player, @NotNull Collection<Player> recipients, @NotNull Function<PlayerChatEvent, Component> defaultChatFormat, @NotNull String message) -
Method Summary
Modifier and TypeMethodDescription@NotNull Function
<@NotNull PlayerChatEvent, @NotNull Component> Used to retrieve the chat format for this message.@NotNull String
Gets the message sent.@NotNull Player
Gets the player.@NotNull Collection
<Player> Those are 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
setChatFormat
(@NotNull Function<PlayerChatEvent, Component> chatFormat) Changes the chat format.void
setMessage
(@NotNull String message) Used to change the message.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 Function<PlayerChatEvent, Component> defaultChatFormat, @NotNull @NotNull String message)
-
-
Method Details
-
setChatFormat
Changes the chat format.- Parameters:
chatFormat
- the custom chat format
-
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
Gets the message sent.- Returns:
- the sender's message
-
setMessage
Used to change the message.- Parameters:
message
- the new message
-
getChatFormatFunction
@NotNull public @NotNull Function<@NotNull PlayerChatEvent,@NotNull Component> getChatFormatFunction()Used to retrieve the chat format for this message.- Returns:
- the chat format which will be used
-
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
-