Class BroadcastDeliverEvent

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

public final class BroadcastDeliverEvent extends ZentrixEvent implements org.bukkit.event.Cancellable
Called just before a broadcast is sent, whether its timer came due or it was triggered through BroadcastService#triggerBroadcastNow.

Listeners can narrow the audience - getRecipients() allows removing players, never adding them, so a broadcast cannot leak into a match or lobby it was not meant for - replace the text, or cancel this delivery. Cancelling does not give the timer back: the broadcast is next due one interval later, as if it had been sent. Text is in Zentrix's colour format, before formatting. BroadcastSentEvent follows once it has been sent.

Main thread; only fired while a listener is registered.

Since:
1.8.0
  • Constructor Details

  • Method Details

    • getBroadcastId

      @NotNull public @NotNull String getBroadcastId()
      The broadcast's id.
    • getType

      @NotNull public @NotNull BroadcastType getType()
      How it is shown.
    • getOrigin

      @NotNull public @NotNull BroadcastDeliverEvent.Origin getOrigin()
      Where the broadcast comes from and what sent it now.
    • getStates

      @NotNull public @NotNull Set<GameState> getStates()
      The states whose players it was sent to.
    • getRecipients

      @NotNull public @NotNull Set<org.bukkit.entity.Player> getRecipients()
      The players it will be sent to. Remove players to keep it from them; adding is not supported and throws UnsupportedOperationException.
    • getLines

      @NotNull public @NotNull List<String> getLines()
      The chat lines of a BroadcastType.CHAT broadcast; empty for other types.
    • setLines

      public void setLines(@NotNull @NotNull List<String> lines)
      Replaces the chat lines of a BroadcastType.CHAT broadcast.
    • getTitle

      @NotNull public @NotNull Optional<String> getTitle()
      The title of a BroadcastType.TITLE broadcast.
    • setTitle

      public void setTitle(@Nullable @Nullable String title)
      Replaces the title of a BroadcastType.TITLE broadcast; null for none.
    • getSubtitle

      @NotNull public @NotNull Optional<String> getSubtitle()
      The subtitle of a BroadcastType.TITLE broadcast.
    • setSubtitle

      public void setSubtitle(@Nullable @Nullable String subtitle)
      Replaces the subtitle of a BroadcastType.TITLE broadcast; null for none.
    • getActionBar

      @NotNull public @NotNull Optional<String> getActionBar()
      The text of an BroadcastType.ACTIONBAR broadcast.
    • setActionBar

      public void setActionBar(@Nullable @Nullable String actionBar)
      Replaces the text of an BroadcastType.ACTIONBAR broadcast; null for none.
    • 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()