Package de.marcely.bedwars.tools
Class VarSound
java.lang.Object
de.marcely.bedwars.tools.VarSound
- All Implemented Interfaces:
- Cloneable
Easy solution for playing vanilla and custom sounds while retaining async support.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionclone()static VarSoundCreates a VarSound from a vanilla sound.static VarSoundfromCustom(String name) Creates a VarSound from a custom sound.abstract SoundReturns the bukkit enum of the sound.abstract StringgetName()Returns the name of the sound.floatgetPitch()Returns the pitch of the sound.floatReturns the volume of the sound.booleanisActive()Returns whether this sound is active.abstract booleanReturns whether this sound is a vanilla sound or whether it's a custom sound that requires a resource pack.static VarSoundparse(ConfigurationSection config) Parses a sound from aConfigurationSection.voidPlays the sound to the player at the location of the player.voidPlays the sound to the player at the given location.abstract voidPlays the sound to the player at the given location.voidPlays the sound at the given location.abstract voidPlays the sound at the given location.Serializes this sound into aConfigurationSection.setActive(boolean active) Sets whether this sound is active.setPitch(float pitch) Sets the pitch of the sound.setVolume(float volume) Sets the volume of the sound.
- 
Constructor Details- 
VarSoundpublic VarSound()
 
- 
- 
Method Details- 
isVanillapublic abstract boolean isVanilla()Returns whether this sound is a vanilla sound or whether it's a custom sound that requires a resource pack.- Returns:
- trueif it's a vanilla sound,- falseotherwise
 
- 
getNameReturns the name of the sound.If it's a vanilla sound, it returns Enum.name().- Returns:
- The name of the sound
 
- 
getBukkitEnumReturns the bukkit enum of the sound.- Returns:
- The bukkit enum of the sound. May be nullif it's not present
 
- 
getVolumepublic float getVolume()Returns the volume of the sound.Default is 1.- Returns:
- The volume of the sound
 
- 
setVolumeSets the volume of the sound.- Parameters:
- volume- The volume of the sound
- Returns:
- Returns this exact instance
 
- 
getPitchpublic float getPitch()Returns the pitch of the sound.Default is 1.- Returns:
- The pitch of the sound
 
- 
setPitchSets the pitch of the sound.- Parameters:
- pitch- The pitch of the sound
- Returns:
- Returns this exact instance
 
- 
isActivepublic boolean isActive()Returns whether this sound is active.If it's not active, it won't play. - Returns:
- trueif it's active,- falseotherwise
 
- 
setActiveSets whether this sound is active.If it's not active, it won't play. - Parameters:
- active-- trueif it's active,- falseotherwis
- Returns:
- Returns this exact instancee
 
- 
playpublic abstract void play(Player player, Location loc, @Nullable @Nullable Float overrideVolume, @Nullable @Nullable Float overridePitch) Plays the sound to the player at the given location.- Parameters:
- player- The player to play the sound to
- loc- The location to play the sound at
- overrideVolume- The volume to play the sound at. If- null, it uses- getVolume()
- overridePitch- The pitch to play the sound at. If- null, it uses- getPitch()
 
- 
playpublic abstract void play(Location loc, @Nullable @Nullable Float overrideVolume, @Nullable @Nullable Float overridePitch) Plays the sound at the given location.- Parameters:
- loc- The location to play the sound at
- overrideVolume- The volume to play the sound at. If- null, it uses- getVolume()
- overridePitch- The pitch to play the sound at. If- null, it uses- getPitch()
 
- 
playPlays the sound to the player at the given location.- Parameters:
- player- The player to play the sound to
- loc- The location to play the sound at
 
- 
playPlays the sound to the player at the location of the player.- Parameters:
- player- The player to play the sound to
 
- 
playPlays the sound at the given location.- Parameters:
- loc- The location to play the sound at
 
- 
clone
- 
serializeAsConfigSerializes this sound into aConfigurationSection. It includes the following keys:- name: The name of the sound (required)
- is-active: Whether the sound is active (default: true)
- is-custom-resourcepack: Whether the sound is a custom sound that requires a resource pack (default: false)
- volume: The volume of the sound (default: 1.0)
- pitch: The pitch of the sound (default: 1.0)
 - Returns:
- The serialized sound
 
- 
parseParses a sound from aConfigurationSection. It includes the following keys:- name: The name of the sound (required)
- is-active: Whether the sound is active (default: true)
- is-custom-resourcepack: Whether the sound is a custom sound that requires a resource pack (default: false)
- volume: The volume of the sound (default: 1.0)
- pitch: The pitch of the sound (default: 1.0)
 - Parameters:
- config- The config to parse
- Returns:
- The parsed sound
- Throws:
- IllegalArgumentException- If the config is invalid
 
- 
fromCreates a VarSound from a vanilla sound.- Parameters:
- sound- The sound
- Returns:
- The created wrapper
 
- 
fromCustomCreates a VarSound from a custom sound.- Parameters:
- name- The name of the sound
- Returns:
- The created wrapper
 
 
-