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
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 ClassesModifier and TypeClassDescriptionstatic enumWhere Zentrix routed a chat message.Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result -
Constructor Summary
ConstructorsConstructorDescriptionChatMessageEvent(@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 TypeMethodDescriptionstatic @NotNull org.bukkit.event.HandlerList@NotNull org.bukkit.event.HandlerListGets the handler list for this event.@NotNull net.kyori.adventure.text.ComponentThe formatted message every recipient will receive.@NotNull StringWhat 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.@NotNull ChatMessageEvent.RoutegetRoute()The audience the message was routed to.@NotNull org.bukkit.entity.PlayerThe player who wrote the message.booleanvoidsetCancelled(boolean cancelled) voidsetMessage(@NotNull net.kyori.adventure.text.Component message) Replaces the formatted message.Methods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
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
The audience the message was routed to. -
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
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 throwsUnsupportedOperationException. -
isCancelled
public boolean isCancelled()- Specified by:
isCancelledin interfaceorg.bukkit.event.Cancellable
-
setCancelled
public void setCancelled(boolean cancelled) - Specified by:
setCancelledin interfaceorg.bukkit.event.Cancellable
-
getHandlers
@NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()Description copied from class:ZentrixEventGets the handler list for this event.- Overrides:
getHandlersin classZentrixEvent- Returns:
- The handler list
-
getHandlerList
@NotNull public static @NotNull org.bukkit.event.HandlerList getHandlerList()
-