Class MutableAudienceForwarder

java.lang.Object
me.totalfreedom.audience.MutableAudienceForwarder
All Implemented Interfaces:
net.kyori.adventure.audience.Audience, net.kyori.adventure.pointer.Pointered

public class MutableAudienceForwarder extends Object implements net.kyori.adventure.audience.Audience
A replacement for ForwardingAudience that allows for audiences to be removed and added at will. Not thread safe.

This is intended for use in toggleable logging systems, for example, potion spy.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addAudience(net.kyori.adventure.audience.Audience audience)
    Adds an audience to this forwarder.
    void
     
    void
    deleteMessage(@NotNull net.kyori.adventure.chat.SignedMessage signedMessage)
    Deletes a signed message from the audiences chat.
    void
    deleteMessage(@NotNull net.kyori.adventure.chat.SignedMessage.Signature signature)
    Deletes a signed message from the audiences chat using the provided chat signature.
    @NotNull net.kyori.adventure.audience.Audience
    filterAudience(@NotNull Predicate<? super net.kyori.adventure.audience.Audience> filter)
    Filters the audiences in the stream by the given predicate.
    void
    forEachAudience(@NotNull Consumer<? super net.kyori.adventure.audience.Audience> action)
    Applies a consumer to each audience in the stream.
    from(net.kyori.adventure.audience.Audience... audiences)
    Creates a new MutableAudienceForwarder with the given audiences.
    void
    hideBossBar(@NotNull net.kyori.adventure.bossbar.BossBar bar)
     
    void
    openBook(@NotNull net.kyori.adventure.inventory.Book book)
     
    void
    openBook(@NotNull net.kyori.adventure.inventory.Book.Builder book)
     
    void
    playSound(@NotNull net.kyori.adventure.sound.Sound sound)
     
    void
    playSound(@NotNull net.kyori.adventure.sound.Sound sound, double x, double y, double z)
     
    void
    playSound(@NotNull net.kyori.adventure.sound.Sound sound, @NotNull net.kyori.adventure.sound.Sound.Emitter emitter)
     
    boolean
    removeAudience(net.kyori.adventure.audience.Audience audience)
    Removes an audience from this forwarder.
    void
     
    void
    sendActionBar(@NotNull net.kyori.adventure.text.Component message)
     
    void
    sendActionBar(@NotNull net.kyori.adventure.text.ComponentLike message)
     
    void
    sendMessage(@NotNull net.kyori.adventure.chat.SignedMessage signedMessage, @NotNull net.kyori.adventure.chat.ChatType.Bound boundChatType)
    Sends a SignedMessage to every audience within the stream.
    void
    sendMessage(@NotNull net.kyori.adventure.text.Component message)
    Sends a Component to every audience within the stream.
    void
    sendMessage(@NotNull net.kyori.adventure.text.ComponentLike message)
    Sends a ComponentLike to every audience within the stream.
    void
    sendMessage(@NotNull net.kyori.adventure.text.ComponentLike message, @NotNull net.kyori.adventure.chat.ChatType.Bound boundChatType)
    Sends a SignedMessage to every audience within the stream.
    void
    sendMessage(@NotNull net.kyori.adventure.text.Component message, @NotNull net.kyori.adventure.chat.ChatType.Bound boundChatType)
    Sends a SignedMessage to every audience within the stream.
    void
    sendPlayerListFooter(@NotNull net.kyori.adventure.text.Component footer)
     
    void
    sendPlayerListFooter(@NotNull net.kyori.adventure.text.ComponentLike footer)
     
    void
    sendPlayerListHeader(@NotNull net.kyori.adventure.text.Component header)
     
    void
    sendPlayerListHeader(@NotNull net.kyori.adventure.text.ComponentLike header)
     
    void
    sendPlayerListHeaderAndFooter(@NotNull net.kyori.adventure.text.ComponentLike header, @NotNull net.kyori.adventure.text.ComponentLike footer)
     
    void
    sendPlayerListHeaderAndFooter(@NotNull net.kyori.adventure.text.Component header, @NotNull net.kyori.adventure.text.Component footer)
     
    <T> void
    sendTitlePart(@NotNull net.kyori.adventure.title.TitlePart<T> part, T value)
     
    void
    showBossBar(@NotNull net.kyori.adventure.bossbar.BossBar bar)
     
    void
    showTitle(@NotNull net.kyori.adventure.title.Title title)
     
    void
    stopSound(@NotNull net.kyori.adventure.sound.Sound sound)
     
    void
    stopSound(@NotNull net.kyori.adventure.sound.SoundStop stop)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.kyori.adventure.audience.Audience

    sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage

    Methods inherited from interface net.kyori.adventure.pointer.Pointered

    get, getOrDefault, getOrDefaultFrom, pointers
  • Constructor Details

    • MutableAudienceForwarder

      public MutableAudienceForwarder()
  • Method Details

    • from

      public static MutableAudienceForwarder from(net.kyori.adventure.audience.Audience... audiences)
      Creates a new MutableAudienceForwarder with the given audiences.
      Parameters:
      audiences - The audiences to forward to.
      Returns:
      The new MutableAudienceForwarder.
    • addAudience

      public void addAudience(net.kyori.adventure.audience.Audience audience)
      Adds an audience to this forwarder.
      Parameters:
      audience - The audience to add.
    • removeAudience

      public boolean removeAudience(net.kyori.adventure.audience.Audience audience)
      Removes an audience from this forwarder.
      Parameters:
      audience - The audience to remove.
      Returns:
      Whether the audience was removed.
    • filterAudience

      @NotNull public @NotNull net.kyori.adventure.audience.Audience filterAudience(@NotNull @NotNull Predicate<? super net.kyori.adventure.audience.Audience> filter)
      Filters the audiences in the stream by the given predicate.
      Specified by:
      filterAudience in interface net.kyori.adventure.audience.Audience
      Parameters:
      filter - a filter that determines if an audience should be included
      Returns:
      The first Audience found that matches the filter.
    • forEachAudience

      public void forEachAudience(@NotNull @NotNull Consumer<? super net.kyori.adventure.audience.Audience> action)
      Applies a consumer to each audience in the stream.
      Specified by:
      forEachAudience in interface net.kyori.adventure.audience.Audience
      Parameters:
      action - the action to apply.
    • sendMessage

      public void sendMessage(@NotNull @NotNull net.kyori.adventure.text.ComponentLike message)
      Sends a ComponentLike to every audience within the stream.
      Specified by:
      sendMessage in interface net.kyori.adventure.audience.Audience
      Parameters:
      message - The message to send.
      See Also:
    • sendMessage

      public void sendMessage(@NotNull @NotNull net.kyori.adventure.text.Component message)
      Sends a Component to every audience within the stream.
      Specified by:
      sendMessage in interface net.kyori.adventure.audience.Audience
      Parameters:
      message - The message to send
      See Also:
    • sendMessage

      public void sendMessage(@NotNull @NotNull net.kyori.adventure.text.Component message, @NotNull net.kyori.adventure.chat.ChatType.Bound boundChatType)
      Sends a SignedMessage to every audience within the stream.
      Specified by:
      sendMessage in interface net.kyori.adventure.audience.Audience
      Parameters:
      message - the component content of the message
      boundChatType - the bound chat type of the message
      See Also:
    • sendMessage

      public void sendMessage(@NotNull @NotNull net.kyori.adventure.text.ComponentLike message, @NotNull net.kyori.adventure.chat.ChatType.Bound boundChatType)
      Sends a SignedMessage to every audience within the stream.
      Specified by:
      sendMessage in interface net.kyori.adventure.audience.Audience
      Parameters:
      message - the component content of the message
      boundChatType - the bound chat type of the message
      See Also:
    • sendMessage

      public void sendMessage(@NotNull @NotNull net.kyori.adventure.chat.SignedMessage signedMessage, @NotNull net.kyori.adventure.chat.ChatType.Bound boundChatType)
      Sends a SignedMessage to every audience within the stream.
      Specified by:
      sendMessage in interface net.kyori.adventure.audience.Audience
      Parameters:
      signedMessage - the signed message data to send
      boundChatType - the bound chat type of the message
    • deleteMessage

      public void deleteMessage(@NotNull @NotNull net.kyori.adventure.chat.SignedMessage signedMessage)
      Deletes a signed message from the audiences chat.
      Specified by:
      deleteMessage in interface net.kyori.adventure.audience.Audience
      Parameters:
      signedMessage - the message to delete
    • deleteMessage

      public void deleteMessage(@NotNull net.kyori.adventure.chat.SignedMessage.Signature signature)
      Deletes a signed message from the audiences chat using the provided chat signature.
      Specified by:
      deleteMessage in interface net.kyori.adventure.audience.Audience
      Parameters:
      signature - the signature associated with the message to delete.
    • sendActionBar

      public void sendActionBar(@NotNull @NotNull net.kyori.adventure.text.ComponentLike message)
      Specified by:
      sendActionBar in interface net.kyori.adventure.audience.Audience
    • sendActionBar

      public void sendActionBar(@NotNull @NotNull net.kyori.adventure.text.Component message)
      Specified by:
      sendActionBar in interface net.kyori.adventure.audience.Audience
    • sendPlayerListHeader

      public void sendPlayerListHeader(@NotNull @NotNull net.kyori.adventure.text.ComponentLike header)
      Specified by:
      sendPlayerListHeader in interface net.kyori.adventure.audience.Audience
    • sendPlayerListHeader

      public void sendPlayerListHeader(@NotNull @NotNull net.kyori.adventure.text.Component header)
      Specified by:
      sendPlayerListHeader in interface net.kyori.adventure.audience.Audience
    • sendPlayerListFooter

      public void sendPlayerListFooter(@NotNull @NotNull net.kyori.adventure.text.ComponentLike footer)
      Specified by:
      sendPlayerListFooter in interface net.kyori.adventure.audience.Audience
    • sendPlayerListFooter

      public void sendPlayerListFooter(@NotNull @NotNull net.kyori.adventure.text.Component footer)
      Specified by:
      sendPlayerListFooter in interface net.kyori.adventure.audience.Audience
    • sendPlayerListHeaderAndFooter

      public void sendPlayerListHeaderAndFooter(@NotNull @NotNull net.kyori.adventure.text.ComponentLike header, @NotNull @NotNull net.kyori.adventure.text.ComponentLike footer)
      Specified by:
      sendPlayerListHeaderAndFooter in interface net.kyori.adventure.audience.Audience
    • sendPlayerListHeaderAndFooter

      public void sendPlayerListHeaderAndFooter(@NotNull @NotNull net.kyori.adventure.text.Component header, @NotNull @NotNull net.kyori.adventure.text.Component footer)
      Specified by:
      sendPlayerListHeaderAndFooter in interface net.kyori.adventure.audience.Audience
    • showTitle

      public void showTitle(@NotNull @NotNull net.kyori.adventure.title.Title title)
      Specified by:
      showTitle in interface net.kyori.adventure.audience.Audience
    • sendTitlePart

      public <T> void sendTitlePart(@NotNull @NotNull net.kyori.adventure.title.TitlePart<T> part, @NotNull T value)
      Specified by:
      sendTitlePart in interface net.kyori.adventure.audience.Audience
    • clearTitle

      public void clearTitle()
      Specified by:
      clearTitle in interface net.kyori.adventure.audience.Audience
    • resetTitle

      public void resetTitle()
      Specified by:
      resetTitle in interface net.kyori.adventure.audience.Audience
    • showBossBar

      public void showBossBar(@NotNull @NotNull net.kyori.adventure.bossbar.BossBar bar)
      Specified by:
      showBossBar in interface net.kyori.adventure.audience.Audience
    • hideBossBar

      public void hideBossBar(@NotNull @NotNull net.kyori.adventure.bossbar.BossBar bar)
      Specified by:
      hideBossBar in interface net.kyori.adventure.audience.Audience
    • playSound

      public void playSound(@NotNull @NotNull net.kyori.adventure.sound.Sound sound)
      Specified by:
      playSound in interface net.kyori.adventure.audience.Audience
    • playSound

      public void playSound(@NotNull @NotNull net.kyori.adventure.sound.Sound sound, double x, double y, double z)
      Specified by:
      playSound in interface net.kyori.adventure.audience.Audience
    • playSound

      public void playSound(@NotNull @NotNull net.kyori.adventure.sound.Sound sound, @NotNull net.kyori.adventure.sound.Sound.Emitter emitter)
      Specified by:
      playSound in interface net.kyori.adventure.audience.Audience
    • stopSound

      public void stopSound(@NotNull @NotNull net.kyori.adventure.sound.Sound sound)
      Specified by:
      stopSound in interface net.kyori.adventure.audience.Audience
    • stopSound

      public void stopSound(@NotNull @NotNull net.kyori.adventure.sound.SoundStop stop)
      Specified by:
      stopSound in interface net.kyori.adventure.audience.Audience
    • openBook

      public void openBook(@NotNull net.kyori.adventure.inventory.Book.Builder book)
      Specified by:
      openBook in interface net.kyori.adventure.audience.Audience
    • openBook

      public void openBook(@NotNull @NotNull net.kyori.adventure.inventory.Book book)
      Specified by:
      openBook in interface net.kyori.adventure.audience.Audience