Interface VoiceApi


public interface VoiceApi
The VoiceApi contains registry, as well as control endpoints for voice-chat related features. This implementation is only available on the Spigot instance, even if the plugin is running in a BungeeCord/Velocity or Vistas network. Accessing this API on a non-spigot instance will result in undefined behavior or runtime exceptions.
  • Method Details

    • getInstance

      static VoiceApi getInstance()
      Get the voice api instance, or null if the plugin is not loaded yet
      Returns:
      instance
    • hasPeer

      boolean hasPeer(Client haystack, Client needle)
      Register a client as a voice-chat peer
      Parameters:
      haystack - The client that will be the host
      needle - The client that will be the peer
      Returns:
      true if the client was registered, false if the client was already registered
    • hasPeer

      boolean hasPeer(Client haystack, UUID needle)
      Register a client as a voice-chat peer
      Parameters:
      haystack - The client that will be the host
      needle - The client that will be the peer
      Returns:
      true if the client was registered, false if the client was already registered
    • updatePeerOptions

      void updatePeerOptions(Client client, Client peerToUpdate, VoicePeerOptions options)
      Push new options for a peer, changing how its rendered in the client
      Parameters:
      client - The web client that should receive this update
      peerToUpdate - The peer that should be updated
      options - The new options
    • addStaticPeer

      void addStaticPeer(Client client, Client peerToAdd, boolean visible, boolean mutual)
      Add a peer (partner) to someone's voice chat. This would let the client hear the peerToAdd as a global voice (without spatial audio/distance) until it's removed.
      Parameters:
      client - The web client that should receive this update
      peerToAdd - The peer that should be added
      visible - Whether the peer should be visible in the client
      mutual - Whether the peer should also hear the client (repeat the call for mutual)
    • addStaticPeer

      void addStaticPeer(Client client, Client peerToAdd, boolean visible, boolean mutual, DisplayOverride displayOverride)
      Add a peer (partner) to someone's voice chat. This would let the client hear the peerToAdd as a global voice (without spatial audio/distance) until it's removed.
      Parameters:
      client - The web client that should receive this update
      peerToAdd - The peer that should be added
      visible - Whether the peer should be visible in the client
      mutual - Whether the peer should also hear the client (repeat the call for mutual)
      displayOverride - A display override, which can be used to change the display name and skin of a player in the voice chat system.
      Since:
      6.10.2
    • removeStaticPeer

      void removeStaticPeer(Client client, Client peerToRemove, boolean mutual)
      Remove a global peer from someone's voice chat. This would remove a static peer if they have been added through addStaticPeer, but not if they have been added through the regular voice-chat system.
      Parameters:
      client - The web client that should receive this update
      peerToRemove - The peer that should be removed
      mutual - Whether the peer should also stop hearing the client (repeat the call for mutual)
    • addFilterFunction

      void addFilterFunction(CustomPlayerFilter customPlayerFilter)
      Adds a CustomPlayerFilter to the list of functions to filter out players in com.craftmend.openaudiomc.spigot.modules.voicechat.filters.PeerFilter#wrap(Stream, Player) (which lives in the plugin, not api). These functions are called in com.craftmend.openaudiomc.spigot.modules.voicechat.filters.PeerFilter#wrap(Stream, Player) to allow for plugins to add custom sorting for players. An example being staff members shouldn't be heard by other players so adding a custom function implementation via addFilterFunction(CustomPlayerFilter) allows for such functionality to exist.
      Please read the documentation in the CustomPlayerFilter before planning your implementation, because you are probably better off using the event system for most use-cases.
      Parameters:
      customPlayerFilter - The CustomPlayerFilter to be added to the list of functions
    • getCustomPlayerFilters

      List<CustomPlayerFilter> getCustomPlayerFilters()
      Returns a copy of the internal List of CustomPlayerFilters. This means modifications done to the List returned by this method will not result in changes in the actual list.
      These functions will be called in whatever order they are stored in.
      These functions are called in com.craftmend.openaudiomc.spigot.modules.voicechat.filters.PeerFilter#wrap(Stream, Player) to allow for plugins to add custom sorting for players. An example being staff members shouldn't be heard by other players so adding a custom function implementation via addFilterFunction(CustomPlayerFilter) allows for such functionality to exist.
      Returns:
      A copied List of CustomPlayerFilters
    • getChannels

      Collection<VoiceChannel> getChannels()
      Get a list of all registered channels
      Returns:
      a list of all registered channels
      Since:
      6.10.1
    • getChannel

      @Nullable @Nullable VoiceChannel getChannel(String name)
      Get a channel by its name
      Parameters:
      name - the name of the channel
      Returns:
      the channel, or null if the channel does not exist
      Since:
      6.10.1
    • createChannel

      VoiceChannel createChannel(String name, Client creator, boolean requiresPermission, @Nullable @Nullable String requiredPermission)
      Create a new channel
      Parameters:
      name - the name of the channel
      creator - the creator of the channel
      requiresPermission - if the channel requires permission to join
      requiredPermission - the permission required to join the channel
      Returns:
      the created channel
      Since:
      6.10.1
    • deleteChannel

      void deleteChannel(VoiceChannel channel)
      Delete a channel
      Parameters:
      channel - the channel to delete
      Since:
      6.10.1
    • isChannelNameValid

      boolean isChannelNameValid(String s)
      Check if a channel name is valid
      Parameters:
      s - the name to check
      Returns:
      true if the name is valid
      Since:
      6.10.1