Interface ForwardingAudience

  • All Superinterfaces:
    Audience, Pointered
    All Known Subinterfaces:
    ForwardingAudience.Single
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface ForwardingAudience
    extends Audience
    A receiver that wraps one or more receivers.

    ForwardingAudience is designed to easily allow users or implementations wrap an existing (collection of) Audience(s).

    Since:
    4.0.0
    See Also:
    Audience
    • Method Detail

      • audiences

        @OverrideOnly
        @NotNull
        @NotNull java.lang.Iterable<? extends Audience> audiences()
        Gets the audiences.
        Returns:
        the audiences
        Since:
        4.0.0
      • pointers

        @NotNull
        default @NotNull Pointers pointers()
        Description copied from interface: Pointered
        Gets the pointers for this object.
        Specified by:
        pointers in interface Pointered
        Returns:
        the pointers
      • filterAudience

        @NotNull
        default @NotNull Audience filterAudience​(@NotNull
                                                 @NotNull java.util.function.Predicate<? super Audience> filter)
        Description copied from interface: Audience
        Filters this audience.

        The returned Audience may be the same, or a completely different one.

        Container audiences such as ForwardingAudience may or may not have their own identity. If they do, they may test themselves against the provided filter first, and if the test fails return an empty audience skipping any contained children. If they do not, they must not test themselves against the filter, only testing their children.

        Specified by:
        filterAudience in interface Audience
        Parameters:
        filter - a filter that determines if an audience should be included
        Returns:
        an audience providing a snapshot of all audiences that match the predicate when this method is invoked
      • forEachAudience

        default void forEachAudience​(@NotNull
                                     @NotNull java.util.function.Consumer<? super Audience> action)
        Description copied from interface: Audience
        Executes an action against all audiences.

        If you implement Audience and not ForwardingAudience in your own code, and your audience forwards to other audiences, then you must override this method and provide each audience to action.

        If an implementation of Audience has its own identity distinct from its contained children, it may test itself against the provided filter first, and if the test fails return an empty audience skipping any contained children. If it does not, it must not test itself against the filter, only testing its children.

        Specified by:
        forEachAudience in interface Audience
        Parameters:
        action - the action
      • sendMessage

        default void sendMessage​(@NotNull
                                 @NotNull SignedMessage signedMessage,
                                 @NotNull ChatType.Bound boundChatType)
        Description copied from interface: Audience
        Sends a signed player message to this Audience with the provided bound chat type.
        Specified by:
        sendMessage in interface Audience
        Parameters:
        signedMessage - the signed message data
        boundChatType - the bound chat type
      • sendMessage

        @Deprecated
        default void sendMessage​(@NotNull
                                 @NotNull Identified source,
                                 @NotNull
                                 @NotNull Component message,
                                 @NotNull
                                 @NotNull MessageType type)
        Deprecated.
        Description copied from interface: Audience
        Sends an unsigned player chat message from the given Identified to this Audience with the ChatType corresponding to the provided MessageType.
        Specified by:
        sendMessage in interface Audience
        Parameters:
        source - the source of the message
        message - a message
        type - the type
        See Also:
        Component
      • sendMessage

        @Deprecated
        default void sendMessage​(@NotNull
                                 @NotNull Identity source,
                                 @NotNull
                                 @NotNull Component message,
                                 @NotNull
                                 @NotNull MessageType type)
        Deprecated.
        Description copied from interface: Audience
        Sends a player chat message from the entity represented by the given Identity to this Audience with the ChatType corresponding to the provided MessageType.
        Specified by:
        sendMessage in interface Audience
        Parameters:
        source - the identity of the source of the message
        message - a message
        type - the type
        See Also:
        Component
      • sendActionBar

        default void sendActionBar​(@NotNull
                                   @NotNull Component message)
        Description copied from interface: Audience
        Sends a message on the action bar.
        Specified by:
        sendActionBar in interface Audience
        Parameters:
        message - a message
        See Also:
        Component
      • sendPlayerListHeaderAndFooter

        default void sendPlayerListHeaderAndFooter​(@NotNull
                                                   @NotNull Component header,
                                                   @NotNull
                                                   @NotNull Component footer)
        Description copied from interface: Audience
        Sends the player list header and footer.
        Specified by:
        sendPlayerListHeaderAndFooter in interface Audience
        Parameters:
        header - the header
        footer - the footer
      • sendTitlePart

        default <T> void sendTitlePart​(@NotNull
                                       @NotNull TitlePart<T> part,
                                       @NotNull
                                       T value)
        Description copied from interface: Audience
        Shows a part of a title.
        Specified by:
        sendTitlePart in interface Audience
        Type Parameters:
        T - the type of the value of the part
        Parameters:
        part - the part
        value - the value
      • clearTitle

        default void clearTitle()
        Description copied from interface: Audience
        Clears the title, if one is being displayed.
        Specified by:
        clearTitle in interface Audience
        See Also:
        Title
      • resetTitle

        default void resetTitle()
        Description copied from interface: Audience
        Resets the title and timings back to their default.
        Specified by:
        resetTitle in interface Audience
        See Also:
        Title
      • showBossBar

        default void showBossBar​(@NotNull
                                 @NotNull BossBar bar)
        Description copied from interface: Audience
        Shows a boss bar.
        Specified by:
        showBossBar in interface Audience
        Parameters:
        bar - a boss bar
        See Also:
        BossBar
      • hideBossBar

        default void hideBossBar​(@NotNull
                                 @NotNull BossBar bar)
        Description copied from interface: Audience
        Hides a boss bar.
        Specified by:
        hideBossBar in interface Audience
        Parameters:
        bar - a boss bar
        See Also:
        BossBar
      • playSound

        default void playSound​(@NotNull
                               @NotNull Sound sound,
                               double x,
                               double y,
                               double z)
        Description copied from interface: Audience
        Plays a sound at a location.
        Specified by:
        playSound in interface Audience
        Parameters:
        sound - a sound
        x - x coordinate
        y - y coordinate
        z - z coordinate
        See Also:
        Sound
      • playSound

        default void playSound​(@NotNull
                               @NotNull Sound sound,
                               @NotNull Sound.Emitter emitter)
        Description copied from interface: Audience
        Plays a sound from an emitter, usually an entity.

        Sounds played using this method will follow the emitter unless the sound is a custom sound. In this case the sound will be played at the location of the emitter and will not follow them.

        To play a sound that follows the recipient, use Sound.Emitter.self().

        Note: Due to MC-138832, the volume and pitch may be ignored when using this method.

        Specified by:
        playSound in interface Audience
        Parameters:
        sound - a sound
        emitter - an emitter
      • stopSound

        default void stopSound​(@NotNull
                               @NotNull SoundStop stop)
        Description copied from interface: Audience
        Stops a sound, or many sounds.
        Specified by:
        stopSound in interface Audience
        Parameters:
        stop - a sound stop
        See Also:
        SoundStop
      • openBook

        default void openBook​(@NotNull
                              @NotNull Book book)
        Description copied from interface: Audience
        Opens a book.

        When possible, no item should persist after closing the book.

        Specified by:
        openBook in interface Audience
        Parameters:
        book - a book
        See Also:
        Book
      • sendResourcePacks

        default void sendResourcePacks​(@NotNull
                                       @NotNull ResourcePackRequest request)
        Description copied from interface: Audience
        Sends a request to apply resource packs to this audience.

        Multiple resource packs are only supported since 1.20.3. On older versions, all requests behave as if ResourcePackRequest.replace() is set to true.

        Specified by:
        sendResourcePacks in interface Audience
        Parameters:
        request - the resource pack request
        See Also:
        ResourcePackInfo
      • removeResourcePacks

        default void removeResourcePacks​(@NotNull
                                         @NotNull java.lang.Iterable<java.util.UUID> ids)
        Description copied from interface: Audience
        Clear resource packs with the provided ids if they are present.
        Specified by:
        removeResourcePacks in interface Audience
        Parameters:
        ids - the ids of resource packs to remove
      • removeResourcePacks

        default void removeResourcePacks​(@NotNull
                                         @NotNull java.util.UUID id,
                                         @NotNull
                                         @NotNull java.util.UUID @NotNull ... others)
        Description copied from interface: Audience
        Clear resource packs with the provided ids if they are present.
        Specified by:
        removeResourcePacks in interface Audience
        Parameters:
        id - the id
        others - the ids of any additional resource packs
      • clearResourcePacks

        default void clearResourcePacks()
        Description copied from interface: Audience
        Clear all server-provided resource packs that have been sent to this user.
        Specified by:
        clearResourcePacks in interface Audience