Feature Explanation
Currently there are config values for sounds. Right now that only supports the Sound enum found in the server. Although the enum is just a more convenient way to programmatically play sounds. When using configuration files, it's better to just use the string-based key itself.
Snippet of Sound.java (API Docs - Sound Enum)
public enum Sound implements Keyed {
AMBIENT_BASALT_DELTAS_ADDITIONS("ambient.basalt_deltas.additions"),
AMBIENT_BASALT_DELTAS_LOOP("ambient.basalt_deltas.loop"),
AMBIENT_BASALT_DELTAS_MOOD("ambient.basalt_deltas.mood"),
AMBIENT_CAVE("ambient.cave"),
...
}
With the values of the enum being what they are, you can have the default config value be:
# Add sound effects after skipping the night or storm
sounds:
night-skipped:
enabled: false
sound: ui.toast.challenge_complete
storm-skipped:
enabled: false
sound: entity.wither.spawn
Old config for reference:
# Add sound effects after skipping the night or storm
sounds:
night-skipped:
enabled: false
sound: UI_TOAST_CHALLENGE_COMPLETE
storm-skipped:
enabled: false
sound: ENTITY_WITHER_SPAWN
Doing it this way should be easier for server owners to understand as well, as they don't necessarily understand why it has to be ENTITY_WITHER_SPAWN
, which only makes sense if you're a developer and know enums.
Resources players could use then are naturally also tied to their Minecraft client version, but there are resources like:
They can then just use the command to play sound (command docs):
/playsound <sound> <source> <targets> [x] [y] [z] [volume] [pitch] [minimumVolume]
With the command they first test the sound they want works, then they can update the config value with that after.
Changes Required
Sound Method Being Used
Currently using playSound()
-method that takes Sound enum as paramter. However, there is another method, which is the exact same that takes a String
-value which can be used instead.
See:
Change Methods Getting Sound Effect
Currently ConfigService#getSoundNightSkippedSound() and ConfigService#getSoundStormSkippedSound() uses a try catch to parse the configured value into the enum.
- Try/Catch here is not ideal, as you might want to throw the exception if this is wrongfully configured. Because when someone configures this and leaves the value incorrect, they expect it to work in game, but it won't, and there won't be any errors.
- We don't need to use the Sound enum at all anymore, so this can just return a String instead.