Package valorless.rarespawns.datamodels
Class Sound
java.lang.Object
valorless.rarespawns.datamodels.Sound
Data model representing a sound to be played by RareSpawns.
Stores the sound key (namespaced or legacy) and playback controls (volume and pitch) as floats compatible with the Bukkit API. Not to be confused with the org.bukkit.Sound enum; this model uses string keys to support custom or version-agnostic identifiers.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
key
Namespaced or legacy sound key, e.g. "minecraft:entity.player.levelup" or "ENTITY_PLAYER_LEVELUP". -
volume
Playback volume (float). Typical range: 0.0+; 1.0 is normal. -
pitch
Playback pitch (float). Typical range: about 0.5–2.0; 1.0 is normal.
-
-
Constructor Details
-
Sound
Creates a sound model with the given identifier and playback parameters.- Parameters:
volume- the desired volume as Double (must not be null); converted to floatpitch- the desired pitch as Double (must not be null); converted to floatsound- the sound key identifier (must not be null)
-
-
Method Details
-
parse
Parses a sound definition from a compact string.Expected format:
key:volume:pitchExamples:ENTITY_PLAYER_LEVELUP:0.5:1.2. Behavior:- If the input does not contain a colon or does not have exactly 3 parts, the entire input is treated as the key and volume/pitch default to 1.0.
- If volume or pitch fail to parse as numbers, fall back to defaults (1.0, 1.0).
- Parameters:
string- the input string to parse- Returns:
- a constructed Sound model based on the parsed values or sensible defaults
-
toString
-
play
public void play(org.bukkit.Location location) Plays this sound at the specified location.- Parameters:
location- the location where the sound should be played
-
play
public void play(org.bukkit.entity.Player player) Plays this sound to the specified player.- Parameters:
player- the player where the sound should be played
-