Package com.craftmend.openaudiomc.api
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 Summary
Modifier and TypeMethodDescriptionvoid
addFilterFunction
(CustomPlayerFilter customPlayerFilter) Adds aCustomPlayerFilter
to the list of functions to filter out players incom.craftmend.openaudiomc.spigot.modules.voicechat.filters.PeerFilter#wrap(Stream, Player)
(which lives in the plugin, not api).void
addStaticPeer
(Client client, Client peerToAdd, boolean visible, boolean mutual) Add a peer (partner) to someone's voice chat.void
addStaticPeer
(Client client, Client peerToAdd, boolean visible, boolean mutual, DisplayOverride displayOverride) Add a peer (partner) to someone's voice chat.createChannel
(String name, Client creator, boolean requiresPermission, @Nullable String requiredPermission) Create a new channelvoid
deleteChannel
(VoiceChannel channel) Delete a channel@Nullable VoiceChannel
getChannel
(String name) Get a channel by its nameGet a list of all registered channelsReturns a copy of the internalList
ofCustomPlayerFilter
s.static VoiceApi
Get the voice api instance, or null if the plugin is not loaded yetboolean
Register a client as a voice-chat peerboolean
Register a client as a voice-chat peerboolean
Check if a channel name is validvoid
removeStaticPeer
(Client client, Client peerToRemove, boolean mutual) Remove a global peer from someone's voice chat.void
updatePeerOptions
(Client client, Client peerToUpdate, VoicePeerOptions options) Push new options for a peer, changing how its rendered in the client
-
Method Details
-
getInstance
Get the voice api instance, or null if the plugin is not loaded yet- Returns:
- instance
-
hasPeer
Register a client as a voice-chat peer- Parameters:
haystack
- The client that will be the hostneedle
- The client that will be the peer- Returns:
- true if the client was registered, false if the client was already registered
-
hasPeer
Register a client as a voice-chat peer- Parameters:
haystack
- The client that will be the hostneedle
- The client that will be the peer- Returns:
- true if the client was registered, false if the client was already registered
-
updatePeerOptions
Push new options for a peer, changing how its rendered in the client- Parameters:
client
- The web client that should receive this updatepeerToUpdate
- The peer that should be updatedoptions
- The new options
-
addStaticPeer
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 updatepeerToAdd
- The peer that should be addedvisible
- Whether the peer should be visible in the clientmutual
- 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 updatepeerToAdd
- The peer that should be addedvisible
- Whether the peer should be visible in the clientmutual
- 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
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 updatepeerToRemove
- The peer that should be removedmutual
- Whether the peer should also stop hearing the client (repeat the call for mutual)
-
addFilterFunction
Adds aCustomPlayerFilter
to the list of functions to filter out players incom.craftmend.openaudiomc.spigot.modules.voicechat.filters.PeerFilter#wrap(Stream, Player)
(which lives in the plugin, not api). These functions are called incom.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 viaaddFilterFunction(CustomPlayerFilter)
allows for such functionality to exist.
Please read the documentation in theCustomPlayerFilter
before planning your implementation, because you are probably better off using the event system for most use-cases.- Parameters:
customPlayerFilter
- TheCustomPlayerFilter
to be added to the list of functions
-
getCustomPlayerFilters
List<CustomPlayerFilter> getCustomPlayerFilters()Returns a copy of the internalList
ofCustomPlayerFilter
s. This means modifications done to theList
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 incom.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 viaaddFilterFunction(CustomPlayerFilter)
allows for such functionality to exist.- Returns:
- A copied
List
ofCustomPlayerFilter
s
-
getChannels
Collection<VoiceChannel> getChannels()Get a list of all registered channels- Returns:
- a list of all registered channels
- Since:
- 6.10.1
-
getChannel
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 channelcreator
- the creator of the channelrequiresPermission
- if the channel requires permission to joinrequiredPermission
- the permission required to join the channel- Returns:
- the created channel
- Since:
- 6.10.1
-
deleteChannel
Delete a channel- Parameters:
channel
- the channel to delete- Since:
- 6.10.1
-
isChannelNameValid
Check if a channel name is valid- Parameters:
s
- the name to check- Returns:
- true if the name is valid
- Since:
- 6.10.1
-