-
Notifications
You must be signed in to change notification settings - Fork 9
Voice Chat
The CheatBreaker API allows you to enable voice chat for your server. Voice Data is sent to the game server and forwarded to users in the incoming players' voice channel.
CheatBreakerAPI.getInstance().voiceEnabled(true)
Note: Players will only hear people who are in the same channel as they are.
CheatBreakerAPI.getInstance().createVoiceChannels(VoiceChannel channel...)
Note: Players are not automatically marked as listening to the first channel they are added to.
A player must be in a channel and marked as listening to receive voice data. Players can switch freely between the channels they are added to.
channel.addPlayer(Player player)
CheatBreakerAPI.getInstance().setActiveChannel(Player player, VoiceChannel channel)
channel.removePlayer(Player player)
channel.hasPlayer(Player player)
channel.isListening(Player player)
Below is an example of what is needed to create a global voice channel where anyone can talk.
public class CBVoicePlugin extends JavaPlugin
{
@Override
public void onEnable()
{
CheatBreakerAPI.getInstance().voiceEnabled(true);
final VoiceChannel publicVoiceChannel = new VoiceChannel("Public Channel");
CheatBreakerAPI.getInstance().createVoiceChannels(publicVoiceChannel);
getServer().getPluginManager().registerEvents(
new Listener() {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
publicVoiceChannel.addPlayer(event.getPlayer());
CheatBreakerAPI.getInstance().setActiveChannel(event.getPlayer(), publicVoiceChannel);
}
}, this
);
}
}