Package com.cryptomorin.xseries
Class XSound.SoundPlayer
java.lang.Object
com.cryptomorin.xseries.XSound.SoundPlayer
- Enclosing class:
XSound
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionatLocation(@Nullable org.bukkit.Location location) Plays the sound to all the nearby players (based on the specified volume)forPlayers(@Nullable Collection<org.bukkit.entity.Player> players) Play the sound for the given players.forPlayers(@Nullable 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 @NotNull 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.voidplay()Plays the sound with the given options and updating the player's location.voidplay(Collection<org.bukkit.entity.Player> players, @NotNull org.bukkit.Location updatedLocation) voidplay(@NotNull org.bukkit.Location updatedLocation) Plays the sound with the updated location.voidStops the sound playing to the players that this sound was played to.withRecord(XSound.Record record)
-
Field Details
-
record
-
players
-
heard
-
location
@Nullable public @Nullable org.bukkit.Location 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
public XSound.SoundPlayer forPlayers(@Nullable @Nullable Collection<org.bukkit.entity.Player> players) Play the sound for the given players. -
getHearingPlayers
Gets a list of players who can hear this sound. -
getHearingPlayers
@NotNull public static @NotNull 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
-
play
public void play()Plays the sound with the given options and updating the player's location.- Since:
- 3.0.0
-
play
public void play(@NotNull @NotNull org.bukkit.Location updatedLocation) 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, @NotNull @NotNull 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
-