Class ChatMessageEvent

java.lang.Object
org.bukkit.event.Event
dev.itsharshxd.zentrix.api.events.ZentrixEvent
dev.itsharshxd.zentrix.api.events.chat.ChatMessageEvent
All Implemented Interfaces:
org.bukkit.event.Cancellable

public final class ChatMessageEvent extends ZentrixEvent implements org.bukkit.event.Cancellable
Called just before Zentrix delivers a chat message it formatted itself.

Zentrix formats chat only while chat-formatting is enabled in settings.yml. The message has then already been routed: getRoute() says which audience it was routed to, and getRecipients() holds exactly the players who will receive it. Listeners can rewrite the formatted message, narrow the audience or cancel the delivery. Recipients can only be removed, never added, so a listener cannot carry a message into another match or out of the spectator chat.

With chat formatting disabled Zentrix leaves formatting to other chat plugins and only narrows the viewers of Paper's AsyncChatEvent (at HIGHEST priority); this event is not fired then.

Main thread; only fired while a listener is registered.

Since:
1.8.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Where Zentrix routed a chat message.

    Nested classes/interfaces inherited from class org.bukkit.event.Event

    org.bukkit.event.Event.Result
  • Constructor Summary

    Constructors
    Constructor
    Description
    ChatMessageEvent(@NotNull org.bukkit.entity.Player sender, @NotNull ChatMessageEvent.Route route, @NotNull String plainMessage, @NotNull net.kyori.adventure.text.Component message, @NotNull Collection<? extends org.bukkit.entity.Player> recipients)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static @NotNull org.bukkit.event.HandlerList
     
    @NotNull org.bukkit.event.HandlerList
    Gets the handler list for this event.
    @NotNull net.kyori.adventure.text.Component
    The formatted message every recipient will receive.
    @NotNull String
    What the player typed, as plain text.
    @NotNull Set<org.bukkit.entity.Player>
    The players who will receive the message, the sender included when they would see their own message.
    The audience the message was routed to.
    @NotNull org.bukkit.entity.Player
    The player who wrote the message.
    boolean
     
    void
    setCancelled(boolean cancelled)
     
    void
    setMessage(@NotNull net.kyori.adventure.text.Component message)
    Replaces the formatted message.

    Methods inherited from class org.bukkit.event.Event

    callEvent, getEventName, isAsynchronous

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ChatMessageEvent

      public ChatMessageEvent(@NotNull @NotNull org.bukkit.entity.Player sender, @NotNull @NotNull ChatMessageEvent.Route route, @NotNull @NotNull String plainMessage, @NotNull @NotNull net.kyori.adventure.text.Component message, @NotNull @NotNull Collection<? extends org.bukkit.entity.Player> recipients)
  • Method Details

    • getSender

      @NotNull public @NotNull org.bukkit.entity.Player getSender()
      The player who wrote the message.
    • getRoute

      @NotNull public @NotNull ChatMessageEvent.Route getRoute()
      The audience the message was routed to.
    • getPlainMessage

      @NotNull public @NotNull String getPlainMessage()
      What the player typed, as plain text.
    • getMessage

      @NotNull public @NotNull net.kyori.adventure.text.Component getMessage()
      The formatted message every recipient will receive.
    • setMessage

      public void setMessage(@NotNull @NotNull net.kyori.adventure.text.Component message)
      Replaces the formatted message.
    • getRecipients

      @NotNull public @NotNull Set<org.bukkit.entity.Player> getRecipients()
      The players who will receive the message, the sender included when they would see their own message. Remove players to keep it from them; adding is not supported and throws UnsupportedOperationException.
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface org.bukkit.event.Cancellable
    • setCancelled

      public void setCancelled(boolean cancelled)
      Specified by:
      setCancelled in interface org.bukkit.event.Cancellable
    • getHandlers

      @NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()
      Description copied from class: ZentrixEvent
      Gets the handler list for this event.
      Overrides:
      getHandlers in class ZentrixEvent
      Returns:
      The handler list
    • getHandlerList

      @NotNull public static @NotNull org.bukkit.event.HandlerList getHandlerList()