Class PlayerChatEvent

java.lang.Object
net.minestom.server.event.player.PlayerChatEvent
All Implemented Interfaces:
Event, CancellableEvent, EntityEvent, EntityInstanceEvent, InstanceEvent, PlayerEvent, PlayerInstanceEvent

public class PlayerChatEvent extends Object implements PlayerInstanceEvent, 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

  • Method Details

    • setChatFormat

      public void setChatFormat(@NotNull @NotNull Function<PlayerChatEvent,Component> chatFormat)
      Changes the chat format.
      Parameters:
      chatFormat - the custom chat format
    • getRecipients

      @NotNull public @NotNull 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 @NotNull String getMessage()
      Gets the message sent.
      Returns:
      the sender's message
    • setMessage

      public void setMessage(@NotNull @NotNull String message)
      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 the Event should be cancelled or not.
      Specified by:
      isCancelled in interface CancellableEvent
      Returns:
      true if the event should be cancelled
    • setCancelled

      public void setCancelled(boolean cancel)
      Description copied from interface: CancellableEvent
      Marks the Event as cancelled or not.
      Specified by:
      setCancelled in interface CancellableEvent
      Parameters:
      cancel - true if the event should be cancelled, false otherwise
    • getPlayer

      @NotNull public @NotNull Player getPlayer()
      Description copied from interface: PlayerEvent
      Gets the player.
      Specified by:
      getPlayer in interface PlayerEvent
      Returns:
      the player