### Full workflow example
Source: https://openaudiomc.net/docs/shows
Complete workflow: create show, add cues, start, inspect, and cancel.
```command
/openaudio show create demo
```
```command
/openaudio show add demo 0s command say Welcome to the show!
```
```command
/openaudio show add demo 10s chat @a[region=spawn] &7Enjoy the music!
```
```command
/openaudio show add demo 00:01:00 actionbar @a &eOne minute in...
```
```command
/openaudio show start demo
```
```command
/openaudio show info demo
```
```command
/openaudio show cancel demo
```
--------------------------------
### Start client for previewing language changes
Source: https://openaudiomc.net/docs/client_translations
Run this command in the repository root to start the client for previewing language changes. Requires Node.js and npm. After running, open http://localhost:3000 in a browser.
```bash
cd client/ && npm install --force && npm start
```
--------------------------------
### Build the OpenAudioMc client with npm
Source: https://openaudiomc.net/docs/deploying_web_client
Run these commands in the client directory to install dependencies, lint, and build the OpenAudioMc web client. Requires node and npm installed on the system.
```bash
npm install
npm run lint
npm run build
```
--------------------------------
### Play a sound with custom volume and starting point
Source: https://openaudiomc.net/docs/play_command
Plays a sound with custom volume (70) and starting point (5000 milliseconds).
```text
/oa play @a files:effect.mp3 {"volume":70,"startAtMillis":5000}
```
--------------------------------
### MediaApi.getInstance()
Source: https://openaudiomc.net/docs/play_command
Gets an instance of the media API.
```APIDOC
## getInstance()
### Description
Gets an instance of the media API.
### Method
getInstance
### Parameters
None
### Returns
static MediaApi
```
--------------------------------
### Start or cancel a running show
Source: https://openaudiomc.net/docs/shows
Starts the show or cancels it if it is running.
```command
/openaudio show start demo
```
```command
/openaudio show cancel demo
```
--------------------------------
### MediaApi.createMedia(@NotNull String source)
Source: https://openaudiomc.net/docs/play_command
Creates a new media instance with a source, automatically translating the source if needed and registering a normalized time for the start instant.
```APIDOC
## createMedia(@NotNull String source)
### Description
Creates a new media instance with a source, automatically translating the source if needed and registering a normalized time for the start instant.
### Method
createMedia
### Parameters
- **source** (String) - Required - The media source.
### Returns
@NotNull Media
```
--------------------------------
### Change volume for all players
Source: https://openaudiomc.net/docs/patch_command
Example that sets the volume of media 'my-song' to 60 for all players (@a).
```text
/oa patch @a my-song {"volume":60}
```
--------------------------------
### Add three cues to demo
Source: https://openaudiomc.net/docs/shows
Adds three command cues to the demo show at start, after 1 second, and after 1 minute.
```command
/openaudio show add demo 0s command say I fire at the start
```
```command
/openaudio show add demo 1s command say I fire after one second
```
```command
/openaudio show add demo 1m command say I fire after one minute
```
--------------------------------
### Change speed and fade time for nearest player
Source: https://openaudiomc.net/docs/patch_command
Example that sets speed to 120 and fadeTime to 1000 for media 'my-song' for the nearest player (@p).
```text
/oa patch @p my-song {"speed":120,"fadeTime":1000}
```
--------------------------------
### Get show status
Source: https://openaudiomc.net/docs/shows
Displays information about the specified show, including its state and cues.
```command
/openaudio show info demo
```
--------------------------------
### Language file key-value pair example
Source: https://openaudiomc.net/docs/client_translations
Shows the key-value format of a language file. The key is used by the web client to translate a string, and the value is the translated string. Values can include basic HTML, emojis, and HTML/UTF encoded characters, but cannot include line breaks or raw special characters.
```lang
home.confirmLoginHeader=Welcome back!
home.confirmLoginBody=Are you trying to login as %player? If you are not, please clo
```
--------------------------------
### Maven dependency setup for OpenAudioMc API
Source: https://openaudiomc.net/docs/api
Add the OpenAudioMc API dependency to a Maven project. Requires the Mats public repository. Use version 6.10.16.
```xml
mats-publichttps://repo.mats.coffee/repository/mats-publictruetruecom.craftmend.openaudiomcopenaudiomc-api6.10.16
```
--------------------------------
### MediaApi.getNormalizedCurrentEpoch()
Source: https://openaudiomc.net/docs/play_command
Gets the current epoch time, but normalized to the start of the current media.
```APIDOC
## getNormalizedCurrentEpoch()
### Description
Gets the current epoch time, but normalized to the start of the current media.
### Method
getNormalizedCurrentEpoch
### Parameters
None
### Returns
long
```
--------------------------------
### Gradle dependency setup for OpenAudioMc API
Source: https://openaudiomc.net/docs/api
Add the OpenAudioMc API dependency to a Gradle project. Requires the Mats public repository. Use version 6.10.16.
```groovy
repositories {
maven {
url = uri("https://repo.mats.coffee/repository/mats-public")
}
}
compileOnly("com.craftmend.openaudiomc:openaudiomc-api:6.10.16")
```
--------------------------------
### TrainCarts sign with alias
Source: https://openaudiomc.net/docs/traincarts_integration
Example sign using an alias created with `/openaudiomc alias myTrainMusic https://soundcloud.com/creide13/a-kings-request-cutscene`. The alias is referenced as `a:myTrainMusic`.
```plaintext
[!train]
audio
a:myTrainMusic
```
--------------------------------
### Get a client instance by UUID
Source: https://openaudiomc.net/docs/api
Retrieves a Client object from the ClientApi using a UUID. The client may be null if not online or just joined. Checks if the client is connected to the web client.
```java
UUID myUuid = UUID.fromString("88243ba3-382f-4eb0-874f-c5831eb3c0a6");
Client mats = ClientApi.getInstance().getClient(myUuid);
// the client may be null if they aren't online, or just joined (due to event order)
if (mats == null) {
System.out.println("Mats is not loaded yet, you may need to wait a tick after joining");
return;
}
// lets check if they are connected to the web client
if (mats.isConnected()) {
System.out.println("Mats is connected!");
} else {
System.out.println("Mats is not connected to the web client!");
}
```
--------------------------------
### Cancel proximity voice chat with ClientPeerAddEvent
Source: https://openaudiomc.net/docs/api
Prevents survival players from hearing spectator players in proximity voice chat by cancelling the ClientPeerAddEvent. Only handles the initial connection; if a peer changes gamemode later, use client#kickProximityPeer(client). This example is for single-sided voice chat only; use filters for actual peer filtering.
```java
EventApi.getInstance().registerHandler(ClientPeerAddEvent.class, event -> {
// first of, convert both Clients to a Player
Player player = Bukkit.getPlayer(event.getClient().getActor().getUniqueId());
Player possiblePeer = Bukkit.getPlayer(event.getPeer().getActor().getUniqueId());
if (player.getGameMode() == GameMode.SURVIVAL && possiblePeer.getGameMode() == GameMode.SPECTATOR) {
// cancel the event, as we don't want the players to be able to hear eachother
event.setCancelled(true);
}
});
// this will only handle when the players are initially are being connected to eachother.
// If the peer changes gamemode, you can kick player A using client#kickProximityPeer(client)
```
--------------------------------
### Create a playlist with /openaudiomc playlist create
Source: https://openaudiomc.net/docs/media_playlists
Creates a new playlist with a unique name. The playlist is referenced by this name later, so choose something descriptive like 'my-cool-playlist'.
```bash
/openaudiomc playlist create my-cool-playlist
```
--------------------------------
### Create a new show named demo
Source: https://openaudiomc.net/docs/shows
Creates a new show with the specified name. Required for adding cues.
```command
/openaudio show create demo
```
--------------------------------
### List all playlists with /openaudiomc playlist list
Source: https://openaudiomc.net/docs/media_playlists
Lists all available playlists.
```bash
/openaudiomc playlist list
```
--------------------------------
### Open the show editor GUI (no name)
Source: https://openaudiomc.net/docs/shows
Opens the GUI editor for the show. The show name is not specified in this command.
```command
/openaudio show gui
```
--------------------------------
### Play a playlist in a region (all songs in order) with /openaudiomc region create
Source: https://openaudiomc.net/docs/media_playlists
Assigns a playlist to a region, playing all songs in order. The 'list:' prefix targets the playlist.
```bash
/openaudiomc region create my-region list:my-cool-playlist
```
--------------------------------
### Play a sound for a client
Source: https://openaudiomc.net/docs/api
Constructs a Media object with a source, sets optional properties like loop, volume, and media ID, then plays it for a client using MediaApi.playFor(). The source is automatically translated to the client's format.
```java
// lets construct a media object, the source we pass in here will be automatically translated
Media sound = new Media("files:mysong.mp3");
// configure some pr
sound.setLoop(true);
sound.setVolume(50);
sound.setMediaId("example-sound");
// play the sound for mats (but the last argument is an optional array, so you can play the sound for multiple clients at once)
MediaApi.getInstance().playFor(sound, mats);
```
--------------------------------
### Open the show editor GUI
Source: https://openaudiomc.net/docs/shows
Opens a graphical interface to visually inspect and edit the show.
```command
/openaudio show gui demo
```
--------------------------------
### Add media to a playlist with /openaudiomc playlist add
Source: https://openaudiomc.net/docs/media_playlists
Adds a media source (e.g., SoundCloud song) to an existing playlist. The media source must be valid in the play command.
```bash
/openaudiomc playlist add my-cool-playlist https://soundcloud.com/lobsta-b/not-so-bad
```
--------------------------------
### Basic syntax for /oa play
Source: https://openaudiomc.net/docs/play_command
Basic syntax for the play command. The selector and source are required, while options are optional.
```text
/oa play [options]
```
--------------------------------
### MediaApi.pathMedia(String mediaId, @NotNull MediaPatchOptions options, @NotNull Client... clients)
Source: https://openaudiomc.net/docs/play_command
Updates playing media (like volume, pitch, etc) for a client.
```APIDOC
## pathMedia(String mediaId, @NotNull MediaPatchOptions options, @NotNull Client... clients)
### Description
Updates playing media (like volume, pitch, etc) for a client.
### Method
pathMedia
### Parameters
- **mediaId** (String) - Required - The ID of the media to update.
- **options** (MediaPatchOptions) - Required - The patch options to apply.
- **clients** (Client...) - Required - The clients to update media for.
### Returns
void
```
--------------------------------
### Create an audio region with /oa region create
Source: https://openaudiomc.net/docs/region_command
Creates a region that links a WorldGuard region to a media file. The region name must match the WorldGuard region name. Overlapping regions stack by default; priority support can be enabled in the OpenAudioMc config. The command accepts an optional third argument to set the volume during creation.
```text
/oa region create
```
```text
/oa region create spawn files:spawn-music.mp3
```
--------------------------------
### MediaApi.preloadMedia(Client client, Media media, boolean keepCopy)
Source: https://openaudiomc.net/docs/play_command
Forces a client to preload a media, so it's ready to play when needed.
```APIDOC
## preloadMedia(Client client, Media media, boolean keepCopy)
### Description
Forces a client to preload a media, so it's ready to play when needed.
### Method
preloadMedia
### Parameters
- **client** (Client) - Required - The client to preload media for.
- **media** (Media) - Required - The media to preload.
- **keepCopy** (boolean) - Required - Whether to keep a copy of the media.
### Returns
void
```
--------------------------------
### MediaApi.playFor(@NotNull Media media, @NotNull Client... clients)
Source: https://openaudiomc.net/docs/play_command
Plays a media for a client.
```APIDOC
## playFor(@NotNull Media media, @NotNull Client... clients)
### Description
Plays a media for a client.
### Method
playFor
### Parameters
- **media** (Media) - Required - The media to play.
- **clients** (Client...) - Required - The clients to play the media for.
### Returns
void
```
--------------------------------
### MediaApi.preloadMediaSource(Client client, String mediaSource, boolean keepCopy)
Source: https://openaudiomc.net/docs/play_command
Forces a client to preload a media source, so it's ready to play when needed.
```APIDOC
## preloadMediaSource(Client client, String mediaSource, boolean keepCopy)
### Description
Forces a client to preload a media source, so it's ready to play when needed.
### Method
preloadMediaSource
### Parameters
- **client** (Client) - Required - The client to preload media for.
- **mediaSource** (String) - Required - The media source to preload.
- **keepCopy** (boolean) - Required - Whether to keep a copy of the media.
### Returns
void
```
--------------------------------
### View a playlist with /openaudiomc playlist view
Source: https://openaudiomc.net/docs/media_playlists
Lists all entries of a playlist in chat, allowing you to click on entries to remove them.
```bash
/openaudiomc playlist view my-cool-playlist
```
--------------------------------
### Preload media with MediaApi.preloadMediaSource
Source: https://openaudiomc.net/docs/api
Forcefully preloads media for the client. The keepCopy flag keeps one instance in cache unless explicitly removed, which is useful for repetitive sounds but risks memory leaks.
```java
// this makes the client re-add it to the cache if its played, always keeping one instance ready
// unless it is explicitly removed from the cache. Great for repetitive sounds, but dangerous for memory leaks
boolean keepCopy = true;
// request the client to preload the media from "sound" which we defined earlier
MediaApi.getInstance().preloadMediaSource(mats, sound, keepCopy);
```
--------------------------------
### Play a playlist (random song) with /openaudiomc play
Source: https://openaudiomc.net/docs/media_playlists
Plays a random entry from the playlist. The loop mode determines whether to go through all entries or pick randomly.
```bash
/openaudiomc play @a list:my-cool-playlist
```
--------------------------------
### Configure static voice chat channels in config.yml
Source: https://openaudiomc.net/docs/vc_channels
Configure static voice chat channels in plugins/OpenAudioMc/config.yml. Each channel requires a name, permission, and requirePermission flag. Set requirePermission to false for public channels. Changes require a server restart.
```yaml
# Static channels are a set of channels that will always exist (even if they are empty), and can be locked behind certain permissions
# You can use this feature in cases where individuals don't have permissions to create their own channels, but sitll want to offer
# some groups for global voicechat (like a channel for minigames, off-topic, and roleplay). You can add more values here if you wish,
# or disable the feature entirely. Keep in mind to include all sub values if you add a new channel, and to respect yaml formatting.
# These values are only used on spigot instances
static-channels:
enabled: true
list:
- name: survival
permission: channels.survival
requirePermission: true
- name: off-topic
permission: channels.offtopic
requirePermission: true
- name: staff-chat
permission: channels.staffchat
requirePermission: true
```
--------------------------------
### Listen for client connect events with EventApi
Source: https://openaudiomc.net/docs/api
Shows two ways to listen for client connect events: a single handler via registerHandler, or multiple handlers in a plain object using @Handler annotations. The handler object does not need to implement any interface.
```java
// create a new, single event handler
EventApi.getInstance().registerHandler(ClientConnectEvent.class, event -> {
System.out.println(event.getClient().getActor().getName() + " just connected!");
});
// or register multiple handlers in a handler object (which does not need to implement anything)
EventApi.getInstance().registerHandlers(new Object() {
@Handler
public void onConnect(ClientConnectEvent event) {
System.out.println(event.getClient().getActor().getName() + " just connected!");
}
@Handler
public void onDisconnect(ClientConnectEvent event) {
System.out.println(event.getClient().getActor().getName() + " just disconnected!");
}
});
```
--------------------------------
### Basic usage of /oa patch command
Source: https://openaudiomc.net/docs/patch_command
The general syntax for the patch command. The selector targets players, the id identifies the media, and options is a JSON object of properties to modify.
```text
/oa patch
```
--------------------------------
### UrlMutation Interface
Source: https://openaudiomc.net/docs/media_sources
The UrlMutation interface allows registering custom server-side media hooks or source translators. Implementations can translate custom sources like 'hypixel:' to full media URLs.
```APIDOC
## UrlMutation Interface
### Description
URL mutations can be used to register custom server-side media hooks or source translators. An example use case would be a custom media server aliased by hypixel:, which can be resolved to https://hypixel.com/media/* by a mutation. See the media api for more information.
### Methods
#### onRequest(@NotNull String original)
- **Description**: Translates a custom source to a full media URL.
- **Parameters**:
- original (@NotNull String) - Required
- **Returns**: @NotNull String
```
--------------------------------
### Add cues to a show
Source: https://openaudiomc.net/docs/shows
Adds a cue to the specified show. The data includes timecode, trigger type, and arguments.
```command
/openaudio show add
```
--------------------------------
### New Essentials integration using EventApi
Source: https://openaudiomc.net/docs/api_migration
Shows the new API usage with EventApi and ClientEnableVoiceEvent to block voice chat for muted Essentials users. Uses the new Client interface and EventApi.
```java
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);
}
});
```
--------------------------------
### Delete a playlist with /openaudiomc playlist delete
Source: https://openaudiomc.net/docs/media_playlists
Deletes a playlist and all its entries. This action cannot be undone.
```bash
/openaudiomc playlist delete my-cool-playlist
```
--------------------------------
### Play a sound on loop with fade-in
Source: https://openaudiomc.net/docs/play_command
Plays a sound on loop for a specific player with a fade-in time of 2000 milliseconds.
```text
/oa play @p files:background-music.mp3 {"loop":true,"fadeTime":2000}
```
--------------------------------
### Customize /channel list message formats in config.yml
Source: https://openaudiomc.net/docs/vc_channels
Customize the output of the /channel list command by editing these config values. The item format uses placeholders {channel}, {type}, and {participants}. Adjust to fit server branding or hide elements.
```yaml
# Format messages for the channel list command
voicechat-channel-list-no-channels: '&7&oThere are no voice chat channels available'
voicechat-channel-list-header: '&7&oAvailable voice chat channels and their occupants:'
voicechat-channel-list-item: '&f┌ &b{channel}\n&8├─ &3{type}\n&8└─ &7&o&d{participants}&7&o'
```
--------------------------------
### Media Class
Source: https://openaudiomc.net/docs/media_sources
The Media class represents the full state of a media file, including all settings and options. It provides methods to apply settings and get/set media properties such as volume, speed, fade time, loop, and more.
```APIDOC
## Media Class
### Description
Represents the full state of a media file, including all settings and options. This file is parsed by the client and used to play media of any type, also used internally for regions and speakers.
### Methods
#### applySettings(MediaOptions options)
- **Description**: Applies multiple options to the media.
- **Parameters**:
- options (MediaOptions) - Required
- **Returns**: Media
#### getFadeTime()
- **Description**: Fade time is the amount of milliseconds it takes to fade in or out.
- **Returns**: int
#### getFlag()
- **Description**: The flag of the media, used to identify the type of media.
- **Returns**: MediaFlag
#### getKeepTimeout()
- **Description**: Keep timeout is the number of seconds that the OpenAudioMc plugin runtime should keep track of this media for.
- **Returns**: int
#### getMediaId()
- **Description**: The unique id of the media, used by the client to keep track of media pools.
- **Returns**: String
#### getSource()
- **Description**: Source value for the media.
- **Returns**: String
#### getSpeed()
- **Description**: The speed of the media, 100 by default, but can be used to speed up or slow down the media.
- **Returns**: int
#### getStartAtMillis()
- **Description**: The starting point of the media, in milliseconds.
- **Returns**: int
#### getStartInstant()
- **Description**: An epoch millisecond timestamp of when the media started playing, used by the client to calculate the current position if keepup is configured (time spent + startAtMillis).
- **Returns**: long
#### getVolume()
- **Description**: The volume of the media, 0-100.
- **Returns**: int
#### isDoPickup()
- **Description**: If the media should attempt to pick up where its currently according to the time spent since the start instant.
- **Returns**: boolean
#### isLoop()
- **Description**: If the media should loop (jumping back to startAtMillis and playing again).
- **Returns**: boolean
#### isMuteRegions()
- **Description**: If this media will mute current regions while playing.
- **Returns**: boolean
#### isMuteSpeakers()
- **Description**: If this media will mute the speakers of the client.
- **Returns**: boolean
#### setDoPickup(boolean doPickup)
- **Description**: Sets if the media should attempt to pick up where its currently according to the time spent since the start instant.
- **Parameters**:
- doPickup (boolean) - Required
- **Returns**: void
#### setFadeTime(int fadeTime)
- **Description**: Sets fade time, which is the amount of milliseconds it takes to fade in or out.
- **Parameters**:
- fadeTime (int) - Required
- **Returns**: void
#### setFlag(MediaFlag flag)
- **Description**: Sets the flag of the media, used to identify the type of media.
- **Parameters**:
- flag (MediaFlag) - Required
- **Returns**: void
#### setKeepTimeout(int keepTimeout)
- **Description**: Sets keep timeout, which is the amount of seconds that the OpenAudioMc plugin runtime should keep track of this media for.
- **Parameters**:
- keepTimeout (int) - Required
- **Returns**: void
#### setLoop(boolean loop)
- **Description**: Sets if the media should loop (jumping back to startAtMillis and playing again).
- **Parameters**:
- loop (boolean) - Required
- **Returns**: void
#### setMediaId(String mediaId)
- **Description**: Sets the unique id of the media, used by the client to keep track of media pools.
- **Parameters**:
- mediaId (String) - Required
- **Returns**: void
#### setMuteRegions(boolean muteRegions)
- **Description**: Sets if this media will mute current regions while playing.
- **Parameters**:
- muteRegions (boolean) - Required
- **Returns**: void
#### setMuteSpeakers(boolean muteSpeakers)
- **Description**: Sets if this media will mute the speakers of the client.
- **Parameters**:
- muteSpeakers (boolean) - Required
- **Returns**: void
#### setSource(String source)
- **Description**: Sets source value for the media.
- **Parameters**:
- source (String) - Required
- **Returns**: void
#### setSpeed(int speed)
- **Description**: Sets the speed of the media, 100 by default, but can be used to speed up or slow down the media.
- **Parameters**:
- speed (int) - Required
- **Returns**: void
#### setStartAtMillis(int startAtMillis)
- **Description**: Sets the starting point of the media, in milliseconds.
- **Parameters**:
- startAtMillis (int) - Required
- **Returns**: void
#### setStartInstant(long startInstant)
- **Description**: Sets an epoch millisecond timestamp of when the media started playing, used by the client to calculate the current position if keepup is configured.
- **Parameters**:
- startInstant (long) - Required
- **Returns**: void
#### setVolume(int volume)
- **Description**: Sets the volume of the media, 0-100.
- **Parameters**:
- volume (int) - Required
- **Returns**: void
```
--------------------------------
### MediaApi.stopFor(@NotNull Client... clients)
Source: https://openaudiomc.net/docs/play_command
Stops all media (except regions and speakers) for a client.
```APIDOC
## stopFor(@NotNull Client... clients)
### Description
Stops all media (except regions and speakers) for a client.
### Method
stopFor
### Parameters
- **clients** (Client...) - Required - The clients to stop media for.
### Returns
void
```
--------------------------------
### Add command trigger cue
Source: https://openaudiomc.net/docs/shows
Adds a cue that executes a console command when fired. All following arguments are joined to form the command.
```command
/openaudio show add demo 0s command say I fire at the start
```
--------------------------------
### MediaApi.translateSource(@NotNull String source)
Source: https://openaudiomc.net/docs/play_command
Translates server-sided aliases, playlists or other sources to a valid source.
```APIDOC
## translateSource(@NotNull String source)
### Description
Translates server-sided aliases, playlists or other sources to a valid source.
### Method
translateSource
### Parameters
- **source** (String) - Required - The source to translate.
### Returns
@NotNull String
```
--------------------------------
### MediaApi.stopFor(int fadeTime, @NotNull Client... clients)
Source: https://openaudiomc.net/docs/play_command
Stops all media (except regions and speakers) for a client with a fade time.
```APIDOC
## stopFor(int fadeTime, @NotNull Client... clients)
### Description
Stops all media (except regions and speakers) for a client with a fade time.
### Method
stopFor
### Parameters
- **fadeTime** (int) - Required - The fade time in milliseconds.
- **clients** (Client...) - Required - The clients to stop media for.
### Returns
void
```
--------------------------------
### Connect players with VoiceApi.addStaticPeer
Source: https://openaudiomc.net/docs/api
Connects two players via a static voice stream, making them hear each other regardless of distance. Requires both players to have voice chat enabled; otherwise prints a message and returns. The visible and mutual flags control UI visibility and whether the connection is one-way or mutual.
```java
public void connectAsPhone(Client playerA, Client playerB) {
// ensure both ready
if (!playerA.hasVoicechatEnabled() || !playerB.hasVoicechatEnabled()) {
System.out.println("Both players need to be connected to the web client");
return;
}
// we want the players to see eachother in the UI, setting this to false will hide the player from the UI
boolean visible = true;
// we want the players to be able to hear eachother, setting this to false will only make playerA hear playerB
boolean mutual = true;
VoiceApi.getInstance().addStaticPeer(playerA, playerB, visible, mutual);
}
```
--------------------------------
### Play a sound once for all players
Source: https://openaudiomc.net/docs/play_command
Plays a sound once for all players.
```text
/oa play @a files:welcome.mp3
```
--------------------------------
### Add chat trigger cue
Source: https://openaudiomc.net/docs/shows
Adds a cue that sends a chat message to players matching a selector. The first argument is the selector; the rest is the message.
```command
/openaudio show add demo 1s chat @a[region=spawn] &7Welcome to spawn!
```
--------------------------------
### MediaApi.clearPreloadedMedia(Client client)
Source: https://openaudiomc.net/docs/play_command
Clears all preloaded media for a client, including entries with keepCopy set to true.
```APIDOC
## clearPreloadedMedia(Client client)
### Description
Clears all preloaded media for a client, including entries with keepCopy set to true.
### Method
clearPreloadedMedia
### Parameters
- **client** (Client) - Required - The client whose preloaded media should be cleared.
### Returns
void
```
--------------------------------
### MediaOptions Class
Source: https://openaudiomc.net/docs/media_sources
The MediaOptions class is a model for media options used to configure media objects. It helps apply serialized media options and can be used to set behavior such as volume, looping, and fading.
```APIDOC
## MediaOptions Class
### Description
This class is a model for media options, which are used to configure media objects. Media options are used to configure the behavior of a media object, such as volume, looping, and fading. These can be set on the Media object itself too, but this serves as an intermediate object to help apply serialized media options.
```
--------------------------------
### Stop media with MediaApi.stopFor
Source: https://openaudiomc.net/docs/api
Stops all media with the given ID for the specified client(s). If no ID is given, all media is stopped. Works for multiple clients at once.
```java
MediaApi.getInstance().stopFor("example-sound", mats);
```
--------------------------------
### MediaApi.stopFor(@NotNull String id, int fadeTime, @NotNull Client... clients)
Source: https://openaudiomc.net/docs/play_command
Stops a specific media by ID for a client with a fade time.
```APIDOC
## stopFor(@NotNull String id, int fadeTime, @NotNull Client... clients)
### Description
Stops a specific media by ID for a client with a fade time.
### Method
stopFor
### Parameters
- **id** (String) - Required - The ID of the media to stop.
- **fadeTime** (int) - Required - The fade time in milliseconds.
- **clients** (Client...) - Required - The clients to stop media for.
### Returns
void
```
--------------------------------
### Clear preloaded media with MediaApi.clearPreloadedMedia
Source: https://openaudiomc.net/docs/api
Clears the client's cache of all preloaded media. Specific media cannot be removed individually; this design choice prevents memory leaks.
```java
MediaApi.getInstance().clearPreloadedMedia(mats);
```
--------------------------------
### Remove a playlist entry by index with /openaudiomc playlist remove
Source: https://openaudiomc.net/docs/media_playlists
Removes a specific entry from the playlist by its index (zero-based).
```bash
/openaudiomc playlist remove my-cool-playlist 0
```
--------------------------------
### Add actionbar trigger cue
Source: https://openaudiomc.net/docs/shows
Adds a cue that displays a message in the actionbar to players matching a selector.
```command
/openaudio show add demo 1s actionbar @a &eHeads up!
```
--------------------------------
### MediaApi.stopFor(@NotNull String id, @NotNull Client... clients)
Source: https://openaudiomc.net/docs/play_command
Stops a specific media by ID for a client.
```APIDOC
## stopFor(@NotNull String id, @NotNull Client... clients)
### Description
Stops a specific media by ID for a client.
### Method
stopFor
### Parameters
- **id** (String) - Required - The ID of the media to stop.
- **clients** (Client...) - Required - The clients to stop media for.
### Returns
void
```
--------------------------------
### MediaApi.registerMutation(@NotNull String prefix, @NotNull UrlMutation mutation)
Source: https://openaudiomc.net/docs/play_command
URL mutations can be used to register custom server-side media hooks or source translators.
```APIDOC
## registerMutation(@NotNull String prefix, @NotNull UrlMutation mutation)
### Description
URL mutations can be used to register custom server-side media hooks or source translators.
### Method
registerMutation
### Parameters
- **prefix** (String) - Required - The prefix for the mutation.
- **mutation** (UrlMutation) - Required - The mutation to register.
### Returns
void
```
--------------------------------
### Old Essentials integration using EventDriver
Source: https://openaudiomc.net/docs/api_migration
Shows the old API usage with ApiEventDriver and ClientRequestVoiceEvent to block voice chat for muted Essentials users. Uses the deprecated EventDriver and old Client interface.
```java
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);
}
});
}
```
--------------------------------
### Add a gamemode filter with VoiceApi.addFilterFunction
Source: https://openaudiomc.net/docs/vc_filters
Registers a custom filter that only allows proximity voice chat between players in the same game mode. The filter is implemented as an anonymous CustomPlayerFilter and returns true only when the listener's game mode matches the speaker's. Note that returning false prevents connection, but returning true may be overruled by other filters.
```java
VoiceApi.getInstance().addFilterFunction(new CustomPlayerFilter() {
@Override
public boolean isPlayerValidListener(Player listener, Player speaker) {
return listener.getGameMode() == speaker.getGameMode();
}
});
```
--------------------------------
### TrainCarts sign format
Source: https://openaudiomc.net/docs/traincarts_integration
Place this sign on a train to play audio. The sign must be active at all times as Redstone is not supported. Use an alias to shorten the URL.
```plaintext
[!train]
audio
/stop
```
--------------------------------
### TrainCarts sign to stop music
Source: https://openaudiomc.net/docs/traincarts_integration
Replace the source with `stop` to stop the music for passengers.
```plaintext
[!train]
audio
stop
```
--------------------------------
### Play a sound that mutes regions
Source: https://openaudiomc.net/docs/play_command
Plays a sound that will overwrite all regions temporarily by muting regions.
```text
/oa play @a files:announcement.mp3 {"muteRegions":true}
```
--------------------------------
### Filter proximity voice chat by game mode with addFilterFunction
Source: https://openaudiomc.net/docs/api
Registers a filter that prevents players in different game modes from being linked in proximity voice chat. More efficient than using events because it prevents the voice chat from being created. See the javadoc for addFilterFunction for when it is and isn't invoked.
```java
VoiceApi.getInstance().addFilterFunction((player, peer) -> {
if (player.getGameMode() != peer.getGameMode()) {
// this combination resulted in a negative result, so we need to mark this filter as failed
return false;
}
// they are in the same game mode, so we can allow them to hear eachother (given that the other preconditions are met)
return true;
});
```
--------------------------------
### Disconnect players with VoiceApi.removeStaticPeer
Source: https://openaudiomc.net/docs/api
Disconnects two players from a static voice stream created with addStaticPeer. The true flag makes the removal mutual, also removing playerA from playerB.
```java
public void disconnectAsPhone(Client playerA, Client playerB) {
// the true flag here once again indicates that this is a mutual action, and should also remove playerA from playerB
VoiceApi.getInstance().removeStaticPeer(playerA, playerB, true);
}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.