Package com.cryptomorin.xseries
Class XSound.SoundPlayer
java.lang.Object
com.cryptomorin.xseries.XSound.SoundPlayer
- Enclosing class:
- XSound
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionatLocation
(org.bukkit.Location location) Plays the sound to all the nearby players (based on the specified volume)forPlayers
(Collection<org.bukkit.entity.Player> players) Play the sound for the given players.forPlayers
(org.bukkit.entity.Player... players) Plays the sound only for a single player and no one else can hear it.Collection<org.bukkit.entity.Player>
Gets a list of players who can hear this sound.static Collection<org.bukkit.entity.Player>
getHearingPlayers
(org.bukkit.Location location, double volume) Gets a list of players that can hear this sound at the given location and volume.void
play()
Plays the sound with the given options and updating the player's location.void
play
(Collection<org.bukkit.entity.Player> players, org.bukkit.Location updatedLocation) void
play
(org.bukkit.Location updatedLocation) Plays the sound with the updated location.void
Stops the sound playing to the players that this sound was played to.withRecord
(XSound.Record record)
-
Field Details
-
record
-
players
-
heard
-
location
-
-
Constructor Details
-
SoundPlayer
-
-
Method Details
-
withRecord
-
forPlayers
Plays the sound only for a single player and no one else can hear it. -
atLocation
Plays the sound to all the nearby players (based on the specified volume) -
forPlayers
Play the sound for the given players. -
getHearingPlayers
Gets a list of players who can hear this sound. -
getHearingPlayers
public static Collection<org.bukkit.entity.Player> getHearingPlayers(org.bukkit.Location location, double volume) Gets a list of players that can hear this sound at the given location and volume. This method pretty much uses the default algorithm used by Bukkit.- Parameters:
location
- The location which the sound is going to be played.volume
- The volume of the sound being played. Also seeXSound.Record.volume
- Returns:
-
play
public void play()Plays the sound with the given options and updating the player's location.- Since:
- 3.0.0
-
play
Plays the sound with the updated location. Uses PacketPlayOutNamedSoundEffect.- Parameters:
updatedLocation
- the updated location.- Since:
- 3.0.0
-
play
public void play(Collection<org.bukkit.entity.Player> players, @Nonnull org.bukkit.Location updatedLocation) -
stopSound
public void stopSound()Stops the sound playing to the players that this sound was played to. Note this works fine if the sound was played to one specific player, but for location-based sounds this only works if the players were within the same range as the original volume level.If this is a critical issue you can extend this class and add a cache for all the players that heard the sound.
- Since:
- 7.0.2
-