Package com.jeff_media.jefflib.data
Class SoundData
java.lang.Object
com.jeff_media.jefflib.data.SoundData
Data class to wrap all information needed to play a sound
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SoundData
fromConfigurationSection
(ConfigurationSection config, String prefix) Parses aConfigurationSection
into aSoundData
object.void
playToPlayer
(Player player) Plays the sound only to the given playervoid
playToPlayer
(Player player, Location location) Plays the sound only to the given player, at the given locationvoid
playToWorld
(Location location) Plays the sound to all players in the world, at the given location
-
Constructor Details
-
SoundData
public SoundData()
-
-
Method Details
-
fromConfigurationSection
public static SoundData fromConfigurationSection(@NotNull ConfigurationSection config, @Nullable String prefix) throws IllegalArgumentException Parses aConfigurationSection
into aSoundData
object.Example:
SoundData sound = SoundData.fromConfigurationSection(getConfig().getConfigurationSection("my_sound",null);
Example YAML:
my_sound: effect: AMBIENT_CAVE # case insensitive for builtin sounds, CaSe SeNsItIvE for custom sounds volume: 0.5 # optional, default 1 pitch: 1.5 # optional, default 1 pitch-variant: 0.5 # optional, default 0. If this is set to 0.5, and pitch is set to 1.5, the sound will play with a pitch between 1 and 2 sound-category: MASTER # optional, case insensitive, default MASTER
- Parameters:
config
- ConfigurationSection to parseprefix
- Prefix to use when looking up values in the ConfigurationSection. If non-null, this prefix is prefixed to all keys. For example, if this is set to "foo-", then the keys to look up are "foo-sound", "foo-volume", etc.- Throws:
IllegalArgumentException
- When no sound is defined, or if the sound category is not valid.
-
playToPlayer
Plays the sound only to the given player- Parameters:
player
- Player
-
playToPlayer
Plays the sound only to the given player, at the given location- Parameters:
player
- Playerlocation
- Location
-
playToWorld
Plays the sound to all players in the world, at the given location- Parameters:
location
- Location
-