Skip to content

Commit 38049ac

Browse files
committedMar 8, 2025
feat: Sound class with volume, pitch & category variables
1 parent 6d7304b commit 38049ac

File tree

1 file changed

+38
-0
lines changed
  • api/src/main/java/me/adrigamer2950/adriapi/api/sound

1 file changed

+38
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package me.adrigamer2950.adriapi.api.sound;
2+
3+
import lombok.Builder;
4+
import lombok.NonNull;
5+
import lombok.Value;
6+
import org.bukkit.Location;
7+
import org.bukkit.SoundCategory;
8+
import org.bukkit.entity.Entity;
9+
import org.jetbrains.annotations.NotNull;
10+
11+
@SuppressWarnings("unused")
12+
@Value
13+
@Builder
14+
public class Sound {
15+
16+
@NotNull
17+
@NonNull
18+
org.bukkit.Sound sound;
19+
20+
@Builder.Default
21+
float volume = 1.0f;
22+
23+
@Builder.Default
24+
float pitch = 1.0f;
25+
26+
@NotNull
27+
@NonNull
28+
@Builder.Default
29+
SoundCategory category = SoundCategory.MASTER;
30+
31+
public void playToEntity(Entity entity) {
32+
entity.getWorld().playSound(entity, this.sound, this.category, this.volume, this.pitch);
33+
}
34+
35+
public void playOnLocation(Location l) {
36+
l.getWorld().playSound(l, this.sound, this.category, this.volume, this.pitch);
37+
}
38+
}

0 commit comments

Comments
 (0)
Please sign in to comment.