Files
Blacksmith/src/main/java/net/knarcraft/blacksmith/event/NPCSoundEvent.java

143 lines
3.5 KiB
Java

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 <p>The NPC playing the sound</p>
* @param player <p>The player whose interaction triggered the sound</p>
* @param soundCategory <p>The category the sound is to play in</p>
* @param sound <p>The sound to play</p>
* @param volume <p>The volume of the played sound</p>
* @param pitch <p>The pitch of the played sound</p>
*/
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
*
* @return <p>The pitch of the played sound</p>
*/
public float getPitch() {
return this.pitch;
}
/**
* Gets the volume of the played sound
*
* @return <p>The volume of the played sound</p>
*/
public float getVolume() {
return this.volume;
}
/**
* Gets the category the sound is played in
*
* @return <p>The sound category used</p>
*/
public @NotNull SoundCategory getSoundCategory() {
return this.soundCategory;
}
/**
* Gets the sound to play
*
* @return <p>The sound to play</p>
*/
public @NotNull Sound getSound() {
return this.sound;
}
/**
* Sets the pitch of the played sound
*
* @param pitch <p>The new pitch</p>
*/
public void setPitch(float pitch) {
this.pitch = pitch;
}
/**
* Sets the volume of the played sound
*
* @param volume <p>The new volume</p>
*/
public void setVolume(float volume) {
this.volume = volume;
}
/**
* Sets the sound to play
*
* @param sound <p>The new sound to play</p>
*/
public void setSound(@NotNull Sound sound) {
this.sound = sound;
}
/**
* Sets the category the sound is played in
*
* @param soundCategory <p>The new sound category</p>
*/
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
*
* @return <p>A handler-list with all event handlers</p>
*/
@NotNull
@SuppressWarnings("unused")
public static HandlerList getHandlerList() {
return handlers;
}
@Override
@NotNull
public HandlerList getHandlers() {
return handlers;
}
}