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
ConstructorsConstructorDescriptionPlayerChatEvent(@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 StringGets the message sent.@NotNull PlayerGets the player.@NotNull Collection<Player> Those are the players who will receive the message.booleanGets if theEventshould be cancelled or not.voidsetCancelled(boolean cancel) Marks theEventas cancelled or not.voidsetChatFormat(@NotNull Function<PlayerChatEvent, Component> chatFormat) Changes the chat format.voidsetMessage(@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, waitMethods inherited from interface net.minestom.server.event.trait.EntityInstanceEvent
getInstanceMethods 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: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
-