Migrating your integrations to ^6.10.0

How to migrate your integrations to the new API

Some backstory

The 6.10.0 update contained not only a ton of new features, but also was the biggest house cleaning in the history of the project.
The API now is a first-class citizen and is the main way to interact with the project. It's a stand-alone module, and is also used internally for many components.
Most of the old api still exist (with package names and all), but are all marked as deprecated. They will be removed in the next major release. The old events are still fired as part of a legacy translation layer, but will also be removed.

This is not to encourage the use of the old API, but to make the transition easier for existing users.


The new API is a lot more powerful and flexible. It's also a lot more consistent and easier to use, and provides more flexibility for future updates, while improving the developer experience with proper documentation.
Core new features include

  • cancellable events for voice peers
  • ability to manage media cache and preloading
  • the ability to further control voice chat peers (disabling spatial effects, hiding them from the UI, and more)
  • full support for global voice peers/calls
  • proper api support for custom voice chat filters
  • living javadoc at https://javadoc.openaudiomc.net

Important changes

  • the old Client interface has been retired, but still exists (albeit deprecated) in the old package. The new Client interface is now part of the new package, and has a lot more features but with different signatures.
  • the old EventDriver has been replaced with EventApi, which is a lot more powerful and flexible.

Breaking changes to the public api

  • MediaError has been moved to com.craftmend.openaudiomc.api.media.MediaError


The following events are implemented in the new system with the same name but carry the new Client interface. The counterparts of these events are still fired through the old system for now, but it will print warnings in the console and they will be removed in the future.

  • ClientConnectEvent
  • ClientDisconnectEvent
  • ClientErrorEvent's new version has been renamed to MediaErrorEvent
  • ClientPreAuthEvent's new version has been renamed to ClientAuthenticationEvent
  • ClientRequestVoiceEvent's new version has been renamed to ClientEnableVoiceEvent
  • MicrophoneMuteEvent
  • MicrophoneUnmuteEvent
  • VoicechatDeafenEvent
  • VoicechatUndeafenEvent
  • PlayerConnectVoicechatEvent's new version has been renamed to VoicechatReadyEvent
  • PlayerEnterVoiceProximityEvent is being replaced by ClientPeerAddedEvent, which also includes the options of the peer
  • PlayerLeaveVoiceProximityEvent is being replaced by ClientPeerRemovedEvent, which also includes the options of the peer
  • SystemReloadEvent
  • VoiceChatPeerTickEvent is being replaced by VoicechatPeerTickEvent which now only fires post tick, removing the pre-tick state.

Removed or made private

These events have either been removed because they served no extra purpose or are only available within the plugin package

  • AccountAddTagEvent
  • AccountRemoveTagEvent
  • ClientPreAuthEvent
  • SpigotAudioCommandEvent
  • StateChangeEvent
  • TimeServiceUpdateEvent


Here's an example of how the old essentials integration worked, and how the new API is used in the new implementation.


ApiEventDriver driver = AudioApi.getInstance().getEventDriver(); Essentials ess = (Essentials) Bukkit.getServer().getPluginManager().getPlugin("Essentials"); if (driver.isSupported(ClientRequestVoiceEvent.class)) { driver.on(ClientRequestVoiceEvent.class) .setHandler(event -> { User usr = ess.getUser(event.getRequester().getOwner().getUniqueId()); if (usr == null) return; boolean isMuted = usr.isMuted(); if (isMuted) { OpenAudioLogger.toConsole("Blocking voicechat for " + event.getRequester().getUser().getName() + " because they are muted on Essentials"); event.setCanceled(true); } }); }


EventApi.getInstance().registerHandler(ClientEnableVoiceEvent.class, event -> { User user = ((Essentials) Bukkit.getServer().getPluginManager().getPlugin("Essentials")).getUser(event.getClient().getActor().getUniqueId()); if (user == null) return; if (user.isMuted()) { OpenAudioLogger.warn("Blocking voicechat for " + event.getClient().getActor().getName() + " because they are muted on Essentials"); event.setCancelled(true); } });

Helping out

If you have any questions, feel free to ask in the discord. I'm expecting some people to potentially have issues with the new API, so I'm here to help. Please provide your current implementation or where you're stuck in the development channel, and though I cannot rewrite your code for you, I can help you understand the new API and how to use it.