Proximity VoiceChat Filters
By default, everyone in voicechat will hear everyone else given that they are in the same world and within the configured distance of another.
But there are cases in which you might not want this to be the case. "Filters" exist exactly for these cases.
Built-in Filters
The plugin ships with 3 built-in filters (at the time of writing), which can each be enabled or disabled in the config file (plugins/OpenAudioMc/config.yml
) on spigot installations.
vc-filter.require-same-gamemode
This filter will only expose players to eachother if they are both in the same gamemode (so players in survival will only be able to talk to other players in survival, and so on).
This is useful for a crude minigame setup, where you want to prevent players from communicating with each-other if they are in different states.
vc-filter.require-common-team
The common-team filter hooks into vanilla teams, and will only expose players to eachother if they are in the same team. This is useful for team-based minigames, where you want to prevent players from communicating with the enemy team.
vc-filter.require-no-channel
This filter will exclude players from proximity voicechat while they are in a channel.
With this disabled, players who are talking in a channel will still hear nearby players, and vice versa. Enabling this will cause players who are standing close to someone in a channel to not hear them, and the other way around, with the player who is in a channel only hearing other players in the channel.
For developers
Developers are able to implement custom filters to extend the base functionality (for example implementing parties, friends, or extra moderation). Please consider the following before implementing a custom filter:
- The filter should be as lightweight as possible, because they will called often (please refer to the javadoc link below for details).
- Filters will mean that no proximity voice chat events will be fired for the player combination that got filtered out, and no proximity voicechat communication is possible between the players at all (for as long as the filter is blocked). Please refer to the cancellable event if you wish to still allow one-directional communication.
- Filters do not effect static peers from the API
- Filters will never be ran from the main thread, so you may not use all parts of the Bukkit API.
- The result from your filter may not be definitive. The plugin will not connect players if you return false, but the decision of true may be overruled by another filter. This is to allow for multiple filters to be ran at once.
Example implementation of the gamemode filter
(Note that CustomPlayerFilter
is a @FunctionalInterface
and can be implemented as a lambda)
VoiceApi.getInstance().addFilterFunction(new CustomPlayerFilter() { @Override public boolean isPlayerValidListener(Player listener, Player speaker) { return listener.getGameMode() == speaker.getGameMode(); } });