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 TypeMethodDescriptionvoidaddFilterFunction(CustomPlayerFilter customPlayerFilter) Adds aCustomPlayerFilterto 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).voidaddStaticPeer(Client client, Client peerToAdd, boolean visible, boolean mutual) Add a peer (partner) to someone's voice chat.voidaddStaticPeer(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 channelvoiddeleteChannel(VoiceChannel channel) Delete a channel@Nullable VoiceChannelgetChannel(String name) Get a channel by its nameGet a list of all registered channelsReturns a copy of the internalListofCustomPlayerFilters.static VoiceApiGet the voice api instance, or null if the plugin is not loaded yetbooleanRegister a client as a voice-chat peerbooleanRegister a client as a voice-chat peerbooleanCheck if a channel name is validbooleanisClientModerating(Client client) Check if a client has voicechat moderation enabledvoidremoveStaticPeer(Client client, Client peerToRemove, boolean mutual) Remove a global peer from someone's voice chat.booleanstartClientModeration(Client client) Start a moderation session for a client, bypassing permission checks.voidstopClientModeration(Client client) Stop a moderation session for a clientvoidupdatePeerOptions(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 aCustomPlayerFilterto 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 theCustomPlayerFilterbefore planning your implementation, because you are probably better off using the event system for most use-cases.- Parameters:
customPlayerFilter- TheCustomPlayerFilterto be added to the list of functions
-
getCustomPlayerFilters
List<CustomPlayerFilter> getCustomPlayerFilters()Returns a copy of the internalListofCustomPlayerFilters. This means modifications done to theListreturned 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
ListofCustomPlayerFilters
-
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
-
isClientModerating
Check if a client has voicechat moderation enabled- Parameters:
client- the client to check- Returns:
- true if the client has moderation enabled
- Since:
- 6.10.9
-
startClientModeration
Start a moderation session for a client, bypassing permission checks. Moderation will still have to be enabled in the config, otherwise this method will return false and do nothing. Moderation mode isn't permanent, it will only last for the duration you have configured in the config, but you can call this method again to extend the duration.- Parameters:
client- the client to enable or disable moderation for- Returns:
- true if the client is now moderating
- Since:
- 6.10.9
-
stopClientModeration
Stop a moderation session for a client- Parameters:
client- the client to stop moderation for- Since:
- 6.10.9
-