Class SoundEvent
java.lang.Object
com.github.darksoulq.abyssallib.server.resource.asset.SoundEvent
Represents a logical sound event within Minecraft (e.g., "entity.zombie.ambient").
A SoundEvent acts as the central trigger point that the client listens for. It does
not contain audio itself, but instead houses one or more SoundEntry variants
which point to physical .ogg files on the disk.
-
Constructor Summary
ConstructorsConstructorDescriptionSoundEvent(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull String namespace, @NotNull String eventName) Constructs a new SoundEvent representation. -
Method Summary
Modifier and TypeMethodDescription@NotNull SoundEntryaddVariant(@NotNull String fileName) Adds a physical .ogg file variant to this sound event by attempting to read it from the plugin's internal resources.@NotNull SoundEntryaddVariant(@NotNull String fileName, byte[] data) Adds a physical .ogg file variant to this sound event using raw byte data.@NotNull SoundEventcategory(@NotNull org.bukkit.SoundCategory category) Assigns the master sound category governing this event's volume controls.voidIterates through all registered variants and delegates the physical file byte writing process.@NotNull Stringid()Retrieves the fully qualified namespaced ID of this sound event used by Minecraft clients.voidplay(@NotNull org.bukkit.Location location) Plays this sound event at a specific world location for all nearby players with default volume and pitch.voidplay(@NotNull org.bukkit.Location location, float volume, float pitch) Plays this sound event at a specific world location for all nearby players with customized volume and pitch.voidplay(@NotNull org.bukkit.entity.Player player) Plays this sound event for a specific player at their current location with default volume and pitch.voidplay(@NotNull org.bukkit.entity.Player player, float volume, float pitch) Plays this sound event for a specific player at their current location with customized volume and pitch.@NotNull SoundEventreplace(boolean replace) Determines whether this custom event should completely overwrite a vanilla event of the same name.@NotNull SoundEventAssigns the translation key or raw text to display when the client has subtitles enabled.@NotNull com.google.gson.JsonObjecttoJson()Serializes this event and all its encapsulated entries into the standard sounds.json format.
-
Constructor Details
-
SoundEvent
public SoundEvent(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull String namespace, @NotNull @NotNull String eventName) Constructs a new SoundEvent representation.- Parameters:
plugin- The plugin context for file resolution.namespace- The namespace this event is registered under.eventName- The key identifier for this event.
-
-
Method Details
-
addVariant
Adds a physical .ogg file variant to this sound event by attempting to read it from the plugin's internal resources.- Parameters:
fileName- The path of the .ogg file relative to "resourcepack/{namespace}/sounds/".- Returns:
- The newly generated
SoundEntryto allow for localized variant modifications. - Throws:
RuntimeException- If the specified resource path cannot be found or read.
-
addVariant
Adds a physical .ogg file variant to this sound event using raw byte data.- Parameters:
fileName- The path string where the file should be placed.data- The raw .ogg audio byte array data.- Returns:
- The newly generated
SoundEntryto allow for localized variant modifications.
-
category
Assigns the master sound category governing this event's volume controls.- Parameters:
category- The BukkitSoundCategoryto apply.- Returns:
- This
SoundEventinstance for chaining.
-
subtitle
Assigns the translation key or raw text to display when the client has subtitles enabled.- Parameters:
subtitle- The subtitle string.- Returns:
- This
SoundEventinstance for chaining.
-
replace
Determines whether this custom event should completely overwrite a vanilla event of the same name.- Parameters:
replace- True to replace existing vanilla sounds, false to append variants to them.- Returns:
- This
SoundEventinstance for chaining.
-
play
public void play(@NotNull @NotNull org.bukkit.entity.Player player) Plays this sound event for a specific player at their current location with default volume and pitch.- Parameters:
player- The target player.
-
play
public void play(@NotNull @NotNull org.bukkit.entity.Player player, float volume, float pitch) Plays this sound event for a specific player at their current location with customized volume and pitch.- Parameters:
player- The target player.volume- The volume scalar.pitch- The pitch scalar.
-
play
public void play(@NotNull @NotNull org.bukkit.Location location) Plays this sound event at a specific world location for all nearby players with default volume and pitch.- Parameters:
location- The target origin location.
-
play
public void play(@NotNull @NotNull org.bukkit.Location location, float volume, float pitch) Plays this sound event at a specific world location for all nearby players with customized volume and pitch.- Parameters:
location- The target origin location.volume- The volume scalar.pitch- The pitch scalar.
-
id
Retrieves the fully qualified namespaced ID of this sound event used by Minecraft clients.- Returns:
- The formatted namespaced ID (e.g., "namespace:event_name").
-
emitFiles
-
toJson
@NotNull public @NotNull com.google.gson.JsonObject toJson()Serializes this event and all its encapsulated entries into the standard sounds.json format.- Returns:
- A compiled
JsonObjectrepresenting the sound event logic.
-