package net.knarcraft.blacksmith.event; import net.citizensnpcs.api.npc.NPC; import org.bukkit.Sound; import org.bukkit.SoundCategory; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; /** * An event triggered when an NPC plays a sound indicating an action */ @SuppressWarnings("unused") public class NPCSoundEvent extends AbstractBlacksmithPluginEvent implements Cancellable { private static final HandlerList handlers = new HandlerList(); private boolean cancelled; private float pitch; private float volume; private SoundCategory soundCategory; private Sound sound; /** * Instantiates a new NPC sound event * * @param npc
The NPC playing the sound
* @param playerThe player whose interaction triggered the sound
* @param soundCategoryThe category the sound is to play in
* @param soundThe sound to play
* @param volumeThe volume of the played sound
* @param pitchThe pitch of the played sound
*/ public NPCSoundEvent(@NotNull NPC npc, @NotNull Player player, @NotNull SoundCategory soundCategory, @NotNull Sound sound, float volume, float pitch) { super(npc, player); this.soundCategory = soundCategory; this.sound = sound; this.volume = volume; this.pitch = pitch; } /** * Gets the pitch of the played sound * * @returnThe pitch of the played sound
*/ public float getPitch() { return this.pitch; } /** * Gets the volume of the played sound * * @returnThe volume of the played sound
*/ public float getVolume() { return this.volume; } /** * Gets the category the sound is played in * * @returnThe sound category used
*/ public @NotNull SoundCategory getSoundCategory() { return this.soundCategory; } /** * Gets the sound to play * * @returnThe sound to play
*/ public @NotNull Sound getSound() { return this.sound; } /** * Sets the pitch of the played sound * * @param pitchThe new pitch
*/ public void setPitch(float pitch) { this.pitch = pitch; } /** * Sets the volume of the played sound * * @param volumeThe new volume
*/ public void setVolume(float volume) { this.volume = volume; } /** * Sets the sound to play * * @param soundThe new sound to play
*/ public void setSound(@NotNull Sound sound) { this.sound = sound; } /** * Sets the category the sound is played in * * @param soundCategoryThe new sound category
*/ public void setSoundCategory(@NotNull SoundCategory soundCategory) { this.soundCategory = soundCategory; } @Override public boolean isCancelled() { return this.cancelled; } @Override public void setCancelled(boolean cancelled) { this.cancelled = cancelled; } /** * Gets a handler-list containing all event handlers * * @returnA handler-list with all event handlers
*/ @NotNull @SuppressWarnings("unused") public static HandlerList getHandlerList() { return handlers; } @Override @NotNull public HandlerList getHandlers() { return handlers; } }