Class XSound.Record

java.lang.Object
com.cryptomorin.xseries.XSound.Record
Enclosing class:
XSound

public static class XSound.Record extends Object
A class to help caching sound properties parsed from config.
Since:
3.0.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    org.bukkit.Location
     
    final float
     
    boolean
     
    org.bukkit.entity.Player
     
    final XSound
     
    final float
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Record(XSound sound, org.bukkit.entity.Player player, org.bukkit.Location location, float volume, float pitch, boolean playAtLocation)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    atLocation(org.bukkit.Location location)
    Plays the sound to all the nearby players (based on the specified volume)
    forPlayer(org.bukkit.entity.Player player)
    Plays the sound only for a single player and no one else can hear it.
    forPlayerAtLocation(org.bukkit.entity.Player player, org.bukkit.Location location)
    Plays the sound only for a single player and no on else can hear it.
    void
    Plays the sound with the given options and updating the player's location.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • sound

      @Nonnull public final XSound sound
    • volume

      public final float volume
    • pitch

      public final float pitch
    • playAtLocation

      public boolean playAtLocation
    • player

      @Nullable public org.bukkit.entity.Player player
    • location

      @Nullable public org.bukkit.Location location
  • Constructor Details

    • Record

      public Record(@Nonnull XSound sound, @Nullable org.bukkit.entity.Player player, @Nullable org.bukkit.Location location, float volume, float pitch, boolean playAtLocation)
  • Method Details

    • forPlayer

      public XSound.Record forPlayer(@Nullable org.bukkit.entity.Player player)
      Plays the sound only for a single player and no one else can hear it.
    • atLocation

      public XSound.Record atLocation(@Nullable org.bukkit.Location location)
      Plays the sound to all the nearby players (based on the specified volume)
    • forPlayerAtLocation

      public XSound.Record forPlayerAtLocation(@Nullable org.bukkit.entity.Player player, @Nullable org.bukkit.Location location)
      Plays the sound only for a single player and no on else can hear it. The source of the sound is different and players using headphones may hear the sound with a 3D audio effect.
    • 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(@Nonnull org.bukkit.Location updatedLocation)
      Plays the sound with the updated location.
      Parameters:
      updatedLocation - the updated location.
      Since:
      3.0.0
    • 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