Class FacetAudienceProvider<V,​A extends FacetAudience<V>>

  • All Implemented Interfaces:
    java.lang.AutoCloseable, net.kyori.adventure.audience.Audience, net.kyori.adventure.audience.ForwardingAudience, AudienceProvider

    public abstract class FacetAudienceProvider<V,​A extends FacetAudience<V>>
    extends java.lang.Object
    implements AudienceProvider, net.kyori.adventure.audience.ForwardingAudience
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface net.kyori.adventure.audience.ForwardingAudience

        net.kyori.adventure.audience.ForwardingAudience.Single
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void addViewer​(@NonNull V viewer)
      Adds a viewer.
      @NonNull net.kyori.adventure.audience.Audience all()
      Gets an audience for all online players, including the server's console.
      @NonNull java.lang.Iterable<? extends net.kyori.adventure.audience.Audience> audiences()  
      void changeViewer​(@NonNull V viewer, @NonNull java.util.Locale locale)
      Changes a viewer's locale.
      void close()
      Closes the provider and forces audiences to be empty.
      @NonNull net.kyori.adventure.audience.Audience console()
      Gets an audience for the server's console.
      protected abstract @NonNull A createAudience​(@NonNull java.util.Collection<V> viewers)
      Creates an audience for a collection of viewers.
      @NonNull net.kyori.adventure.audience.Audience filter​(@NonNull java.util.function.Predicate<V> predicate)
      Creates an audience based on a viewer predicate.
      protected abstract @Nullable java.util.UUID hasId​(@NonNull V viewer)
      Gets the UUID of a viewer, if they are a player.
      protected abstract boolean hasPermission​(@NonNull V viewer, @NonNull java.lang.String permission)
      Gets whether a viewer has permission.
      protected abstract boolean isConsole​(@NonNull V viewer)
      Gets whether a viewer is considered console.
      protected abstract boolean isInWorld​(@NonNull V viewer, @NonNull net.kyori.adventure.key.Key world)
      Gets whether a viewer is in a world.
      protected abstract boolean isOnServer​(@NonNull V viewer, @NonNull java.lang.String server)
      Gets whether a viewer is on a server.
      @NonNull net.kyori.adventure.audience.Audience permission​(@NonNull java.lang.String permission)
      Gets or creates an audience containing all viewers with the provided permission.
      @NonNull net.kyori.adventure.audience.Audience player​(@NonNull java.util.UUID playerId)
      Gets an audience for an individual player.
      @NonNull net.kyori.adventure.audience.Audience players()
      Gets an audience for all online players.
      void removeViewer​(@NonNull V viewer)
      Removes a viewer.
      @NonNull net.kyori.adventure.audience.Audience server​(@NonNull java.lang.String serverName)
      Gets an audience for online players on a server, including the server's console.
      @NonNull net.kyori.adventure.audience.Audience world​(@NonNull net.kyori.adventure.key.Key world)
      Gets an audience for online players in a world, including the server's console.
      • 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

        openBook, sendActionBar, sendMessage, sendMessage, sendMessage
      • Methods inherited from interface net.kyori.adventure.audience.ForwardingAudience

        clearTitle, hideBossBar, openBook, playSound, playSound, resetTitle, sendActionBar, sendMessage, showBossBar, showTitle, stopSound
    • Constructor Detail

      • FacetAudienceProvider

        public FacetAudienceProvider()
    • Method Detail

      • addViewer

        public void addViewer​(@NonNull V viewer)
        Adds a viewer.
        Parameters:
        viewer - a viewer
      • removeViewer

        public void removeViewer​(@NonNull V viewer)
        Removes a viewer.
        Parameters:
        viewer - a viewer
      • changeViewer

        public void changeViewer​(@NonNull V viewer,
                                 @NonNull java.util.Locale locale)
        Changes a viewer's locale.
        Parameters:
        viewer - a viewer
        locale - a locale
      • hasId

        protected abstract @Nullable java.util.UUID hasId​(@NonNull V viewer)
        Gets the UUID of a viewer, if they are a player.
        Parameters:
        viewer - a viewer
        Returns:
        a player id or null if not a player
      • isConsole

        protected abstract boolean isConsole​(@NonNull V viewer)
        Gets whether a viewer is considered console.
        Parameters:
        viewer - a viewer
        Returns:
        if the viewer is console
      • hasPermission

        protected abstract boolean hasPermission​(@NonNull V viewer,
                                                 @NonNull java.lang.String permission)
        Gets whether a viewer has permission.
        Parameters:
        viewer - a viewer
        permission - a permission node
        Returns:
        if the viewer has permission
      • isInWorld

        protected abstract boolean isInWorld​(@NonNull V viewer,
                                             @NonNull net.kyori.adventure.key.Key world)
        Gets whether a viewer is in a world.
        Parameters:
        viewer - a viewer
        world - a world name
        Returns:
        if the viewer is in the world
      • isOnServer

        protected abstract boolean isOnServer​(@NonNull V viewer,
                                              @NonNull java.lang.String server)
        Gets whether a viewer is on a server.
        Parameters:
        viewer - a viewer
        server - a server name
        Returns:
        if the viewer is on the server
      • createAudience

        protected abstract @NonNull A createAudience​(@NonNull java.util.Collection<V> viewers)
        Creates an audience for a collection of viewers.
        Parameters:
        viewers - a collection viewers
        Returns:
        an audience
      • audiences

        public @NonNull java.lang.Iterable<? extends net.kyori.adventure.audience.Audience> audiences()
        Specified by:
        audiences in interface net.kyori.adventure.audience.ForwardingAudience
      • all

        public @NonNull net.kyori.adventure.audience.Audience all()
        Description copied from interface: AudienceProvider
        Gets an audience for all online players, including the server's console.

        The audience is dynamically updated as players join and leave.

        Specified by:
        all in interface AudienceProvider
        Returns:
        the players' and console audience
      • console

        public @NonNull net.kyori.adventure.audience.Audience console()
        Description copied from interface: AudienceProvider
        Gets an audience for the server's console.
        Specified by:
        console in interface AudienceProvider
        Returns:
        the console audience
      • players

        public @NonNull net.kyori.adventure.audience.Audience players()
        Description copied from interface: AudienceProvider
        Gets an audience for all online players.

        The audience is dynamically updated as players join and leave.

        Specified by:
        players in interface AudienceProvider
        Returns:
        the players' audience
      • player

        public @NonNull net.kyori.adventure.audience.Audience player​(@NonNull java.util.UUID playerId)
        Description copied from interface: AudienceProvider
        Gets an audience for an individual player.

        If the player is not online, messages are silently dropped.

        Specified by:
        player in interface AudienceProvider
        Parameters:
        playerId - a player uuid
        Returns:
        a player audience
      • filter

        public @NonNull net.kyori.adventure.audience.Audience filter​(@NonNull java.util.function.Predicate<V> predicate)
        Creates an audience based on a viewer predicate.
        Parameters:
        predicate - a predicate
        Returns:
        an audience
      • permission

        public @NonNull net.kyori.adventure.audience.Audience permission​(@NonNull java.lang.String permission)
        Description copied from interface: AudienceProvider
        Gets or creates an audience containing all viewers with the provided permission.

        The audience is dynamically updated as permissions change.

        Specified by:
        permission in interface AudienceProvider
        Parameters:
        permission - the permission to filter sending to
        Returns:
        a permissible audience
      • world

        public @NonNull net.kyori.adventure.audience.Audience world​(@NonNull net.kyori.adventure.key.Key world)
        Description copied from interface: AudienceProvider
        Gets an audience for online players in a world, including the server's console.

        The audience is dynamically updated as players join and leave.

        World identifiers were introduced in Minecraft 1.16. On older game instances, worlds will be assigned the Key minecraft:<world name>

        Specified by:
        world in interface AudienceProvider
        Parameters:
        world - identifier for a world
        Returns:
        the world's audience
      • server

        public @NonNull net.kyori.adventure.audience.Audience server​(@NonNull java.lang.String serverName)
        Description copied from interface: AudienceProvider
        Gets an audience for online players on a server, including the server's console.

        If the platform is not a proxy, the audience defaults to everyone.

        Specified by:
        server in interface AudienceProvider
        Parameters:
        serverName - a server name
        Returns:
        a server's audience
      • close

        public void close()
        Description copied from interface: AudienceProvider
        Closes the provider and forces audiences to be empty.
        Specified by:
        close in interface AudienceProvider
        Specified by:
        close in interface java.lang.AutoCloseable