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 Details

    • PlayerChatEvent

      public PlayerChatEvent​(@NotNull Player sender, @NotNull java.util.Collection<Player> recipients, @NotNull java.lang.String message)
  • 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

      @NotNull public Player getSender()
      Gets the message sender.
      Returns:
      the sender
    • getRecipients

      @NotNull public java.util.Collection<Player> 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

      @Nullable public java.util.function.Function<PlayerChatEvent,​RichMessage> 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