Class PlayerPrefixEvent
PlayerPrefixEvent.Target.TAB: Plex calls this synchronous event on the player's owning region
at join and every 20 ticks.
PlayerPrefixEvent.Target.CHAT: Plex calls this event for each rendered chat line. The event is
asynchronous when Plex renders a normal chat message. The event is synchronous when a
module calls MessageApi.chatLine on a thread that can read the player.
For both targets, read cached state only. Do not perform database or network work.
Each event starts with no prefixes. Add active prefixes on each call; Plex does not
store them. Check getTarget() to contribute to one target only. Unregister
listeners when their plugin or module stops.
Plex renders prefixes in listener order, then the tag, then the name. Plex inserts
one space after each nonempty prefix and tag. In chat, the prefixes and the tag fill the
<prefix> placeholder of chat.format, and the format supplies the space
before the name. The base tag and name are read-only so independent plugins cannot
replace them through this event.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumOutput that Plex renders with the prefixes.Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result -
Field Summary
Fields inherited from class org.bukkit.event.player.PlayerEvent
player -
Constructor Summary
ConstructorsConstructorDescriptionPlayerPrefixEvent(@NotNull org.bukkit.entity.Player player, @NotNull PlayerPrefixEvent.Target target, @NotNull net.kyori.adventure.text.Component name, @NotNull net.kyori.adventure.text.Component tag, boolean async) Creates a fresh prefix request. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPrefix(@NotNull net.kyori.adventure.text.Component prefix) Adds a prefix after prefixes from earlier listeners, before the tag.static @NotNull org.bukkit.event.HandlerListReturns the handler list for this event.@NotNull org.bukkit.event.HandlerList@NotNull net.kyori.adventure.text.ComponentgetName()Returns the base name.@NotNull List<net.kyori.adventure.text.Component> Returns the prefixes contributed so far.@NotNull net.kyori.adventure.text.ComponentgetTag()Returns the base tag.@NotNull PlayerPrefixEvent.TargetReturns the output that Plex will render.Methods inherited from class org.bukkit.event.player.PlayerEvent
getPlayerMethods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
PlayerPrefixEvent
public PlayerPrefixEvent(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull PlayerPrefixEvent.Target target, @NotNull @NotNull net.kyori.adventure.text.Component name, @NotNull @NotNull net.kyori.adventure.text.Component tag, boolean async) Creates a fresh prefix request.- Parameters:
player- player whose chat line or tab-list entry Plex will rendertarget- output that Plex will rendername- name that Plex renders after the tagtag- tag that Plex renders after the prefixes, or an empty component when no tag is setasync- true when Plex calls the event off the server thread
-
-
Method Details
-
getTarget
Returns the output that Plex will render.- Returns:
- chat or tab target
-
getName
@NotNull public @NotNull net.kyori.adventure.text.Component getName()Returns the base name.For
PlayerPrefixEvent.Target.TAB, this is the display name or the rank-colored username. ForPlayerPrefixEvent.Target.CHAT, this is the display name.- Returns:
- base name
-
getTag
@NotNull public @NotNull net.kyori.adventure.text.Component getTag()Returns the base tag.For
PlayerPrefixEvent.Target.TAB, this is the custom tag. ForPlayerPrefixEvent.Target.CHAT, this is the custom tag, or the rank prefix when no custom tag is set.- Returns:
- tag without a separator, or an empty component
-
addPrefix
public void addPrefix(@NotNull @NotNull net.kyori.adventure.text.Component prefix) Adds a prefix after prefixes from earlier listeners, before the tag.- Parameters:
prefix- prefix without a trailing separator; an empty component is ignored
-
getPrefixes
Returns the prefixes contributed so far.- Returns:
- immutable snapshot of prefixes in rendering order
-
getHandlers
@NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()- Specified by:
getHandlersin classorg.bukkit.event.Event
-
getHandlerList
@NotNull public static @NotNull org.bukkit.event.HandlerList getHandlerList()Returns the handler list for this event.- Returns:
- handler list for this event
-