mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-07 07:17:42 +01:00
Some sounds can now use string values instead of just values from the Sound enum
This commit is contained in:
parent
ddd6a994ce
commit
3f1dfc855e
@ -5,26 +5,45 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class SoundReader {
|
||||
private final Sound sound;
|
||||
private final String soundKey;
|
||||
|
||||
public SoundReader(String tag, Sound defaultSound) {
|
||||
if(tag.isEmpty()) {
|
||||
this.sound = defaultSound;
|
||||
this.soundKey = "";
|
||||
return;
|
||||
}
|
||||
|
||||
Sound sound;
|
||||
String soundKey;
|
||||
try {
|
||||
sound = Sound.valueOf(tag);
|
||||
soundKey = "";
|
||||
} catch (Exception e) {
|
||||
sound = defaultSound;
|
||||
sound = null;
|
||||
soundKey = tag;
|
||||
}
|
||||
|
||||
this.sound = sound;
|
||||
this.soundKey = soundKey;
|
||||
}
|
||||
|
||||
public Sound getSound() {
|
||||
return sound;
|
||||
}
|
||||
|
||||
public String getSoundKey() {
|
||||
return soundKey;
|
||||
}
|
||||
|
||||
public void play(Player player) {
|
||||
play(player, 1, 1);
|
||||
}
|
||||
|
||||
public void play(Player player, float vol, float pitch) {
|
||||
player.playSound(player.getLocation(), sound, vol, pitch);
|
||||
if(soundKey.isEmpty())
|
||||
player.playSound(player.getLocation(), sound, vol, pitch);
|
||||
else
|
||||
player.playSound(player.getLocation(), soundKey, vol, pitch);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user