Interface ForwardingAudience.Single

    • Method Detail

      • audience

        @OverrideOnly
        @NotNull
        @NotNull Audience audience()
        Gets the audience.
        Returns:
        the audience
        Since:
        4.0.0
      • get

        @NotNull
        default <T> @NotNull Optional<T> get​(@NotNull
                                             @NotNull Pointer<T> pointer)
        Description copied from interface: Pointered
        Gets the value of pointer.
        Specified by:
        get in interface Pointered
        Type Parameters:
        T - the type
        Parameters:
        pointer - the pointer
        Returns:
        the value
      • getOrDefault

        @Contract("_, null -> null; _, !null -> !null")
        @Nullable
        default <T> T getOrDefault​(@NotNull
                                   @NotNull Pointer<T> pointer,
                                   @Nullable
                                   T defaultValue)
        Description copied from interface: Pointered
        Gets the value of pointer.

        If this Audience is unable to provide a value for pointer, defaultValue will be returned.

        Specified by:
        getOrDefault in interface Pointered
        Type Parameters:
        T - the type
        Parameters:
        pointer - the pointer
        defaultValue - the default value
        Returns:
        the value
      • getOrDefaultFrom

        default <T> @UnknownNullability T getOrDefaultFrom​(@NotNull
                                                           @NotNull Pointer<T> pointer,
                                                           @NotNull
                                                           @NotNull Supplier<? extends T> defaultValue)
        Description copied from interface: Pointered
        Gets the value of pointer.

        If this Audience is unable to provide a value for pointer, the value supplied by defaultValue will be returned.

        Specified by:
        getOrDefaultFrom in interface Pointered
        Type Parameters:
        T - the type
        Parameters:
        pointer - the pointer
        defaultValue - the default value supplier
        Returns:
        the value
      • filterAudience

        @NotNull
        default @NotNull Audience filterAudience​(@NotNull
                                                 @NotNull 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
        Specified by:
        filterAudience in interface ForwardingAudience
        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 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
        Specified by:
        forEachAudience in interface ForwardingAudience
        Parameters:
        action - the action
      • 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
        Specified by:
        sendTitlePart in interface ForwardingAudience
        Type Parameters:
        T - the type of the value of the part
        Parameters:
        part - the part
        value - the value
      • 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
        Specified by:
        playSound in interface ForwardingAudience
        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
        Specified by:
        playSound in interface ForwardingAudience
        Parameters:
        sound - a sound
        emitter - an emitter
      • 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
        Specified by:
        openBook in interface ForwardingAudience
        Parameters:
        book - a book
        See Also:
        Book