Skip to content
This repository was archived by the owner on Nov 1, 2023. It is now read-only.

Development Guide v1

Austin Pilz edited this page Aug 9, 2017 · 1 revision

Plugin Configuration

Soft Depend

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]

Plugin Check

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;
}

How It Works

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.

API Usage

You can play sounds for players using the static methods found in the PlayerSoundAPI class:

Play Custom Sound

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.json file 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.

Currently Playing

To check if there is one or more custom sounds playing for a player:

PlayerSoundAPI.isSoundCurrentlyPlayingForPlayer(player);

Stop All Sounds

To stop all currently playing custom sounds for a player:

PlayerSoundAPI.getPlayerSoundManager(player).stopAllSounds();

Clone this wiki locally