-
Notifications
You must be signed in to change notification settings - Fork 0
Development Guide v1
If your plugin is going to require the use of CustomSoundManagerAPI, it's advised that you add the following line to your plugin.yml file, softdepend: [CustomSoundManagerAPI]
The following code checks to see if CustomSoundManagerAPI is installed and running on the server, halting your plugin startup if it can't find CustomSoundManagerAPI:
if (!Bukkit.getPluginManager().isPluginEnabled("CustomSoundManagerAPI"))
{
log.log(Level.SEVERE, consolePrefix + "CustomSoundManagerAPI not found - required for gameplay.");
this.setEnabled(false);
return;
}
CustomSoundManagerAPI allows plugin developers to play custom sounds in resource packs for players. The only requirements is that CustomSoundManagerAPI is running on the server and that the player has the custom resource pack installed in their client.
The plugin manages all of the custom sounds playing for a user. It enables you to play a sound, either alongside currently playing sounds or interrupting any currently playing.
You can play sounds for players using the static methods found in the PlayerSoundAPI class:
The following code guide can be used to play a custom sound for a player:
PlayerSoundAPI.getPlayerSoundManager(player).playCustomSound(location, "custom.exampleSoundEffectName", lengthInSeconds, volume, interrupt);- player - The player object of the player you wish to play a sound for.
- location - The location at which the sound should originate and play from. (Most commonly just the players location).
- sound - String name of the custom sound found in the
sounds.jsonfile of the resource pack. - length - Length in seconds that the sound plays for.
- volume - Volume that the sound should play at.
- interrupt - Boolean if the new sound should interrupt (true) currently playing sounds, or should overlay (false) and play along with any currently playing sounds.
To check if there is one or more custom sounds playing for a player:
PlayerSoundAPI.isSoundCurrentlyPlayingForPlayer(player);To stop all currently playing custom sounds for a player:
PlayerSoundAPI.getPlayerSoundManager(player).stopAllSounds();