Class SoundUtil

java.lang.Object
net.glowstone.util.SoundUtil

public class SoundUtil extends Object
A collection of utility methods to play sounds.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.bukkit.SoundCategory
    Convert a string to a SoundCategory.
    static void
    playSoundAtLocationExcept(org.bukkit.Location location, org.bukkit.Sound sound, float volume, float pitch, GlowPlayer... exclude)
    Plays a sound with a random pitch, but excludes specified players from hearing it.
    static void
    playSoundPitchRange(org.bukkit.Location location, org.bukkit.Sound sound, float volume, float pitchBase, float pitchRange, boolean allowNegative, GlowPlayer... exclude)
    Plays a sound with a random pitch, but excludes specified players from hearing it.
    static void
    playSoundPitchRange(org.bukkit.Location location, org.bukkit.Sound sound, float volume, float pitchBase, float pitchRange, GlowPlayer... exclude)
    Plays a sound with a random pitch, but excludes specified players from hearing it.
    static float
    randomReal(float range)
    Generates a random float between -range and range.

    Methods inherited from class java.lang.Object

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

    • SoundUtil

      public SoundUtil()
  • Method Details

    • playSoundAtLocationExcept

      public static void playSoundAtLocationExcept(org.bukkit.Location location, org.bukkit.Sound sound, float volume, float pitch, GlowPlayer... exclude)
      Plays a sound with a random pitch, but excludes specified players from hearing it.
      Parameters:
      location - the sound location
      sound - the sound to play
      volume - the volume multiplier
      pitch - the pitch modifier
      exclude - the players not to play the sound for
      Throws:
      NullPointerException - if any of the location, sound, or exclude parameters is null.
    • playSoundPitchRange

      public static void playSoundPitchRange(org.bukkit.Location location, org.bukkit.Sound sound, float volume, float pitchBase, float pitchRange, boolean allowNegative, GlowPlayer... exclude)
      Plays a sound with a random pitch, but excludes specified players from hearing it.
      Parameters:
      location - the sound location
      sound - the sound to play
      volume - the volume multiplier
      pitchBase - if allowNegative, the average pitch modifier; otherwise, the minimum
      pitchRange - the maximum deviation of the pitch modifier compared to pitchBase
      allowNegative - if true, distribution is triangular rather than uniform
      exclude - the players not to play the sound for
    • playSoundPitchRange

      public static void playSoundPitchRange(org.bukkit.Location location, org.bukkit.Sound sound, float volume, float pitchBase, float pitchRange, GlowPlayer... exclude)
      Plays a sound with a random pitch, but excludes specified players from hearing it.
      Parameters:
      location - the sound location
      sound - the sound to play
      volume - the volume multiplier
      pitchBase - the average pitch modifier.
      pitchRange - the maximum deviation of the pitch modifier compared to pitchBase
      exclude - the players not to play the sound for
    • randomReal

      public static float randomReal(float range)
      Generates a random float between -range and range.
      Parameters:
      range - the bounds of the random float.
      Returns:
      A randomly generated float.
    • buildSoundCategory

      public static org.bukkit.SoundCategory buildSoundCategory(String category)
      Convert a string to a SoundCategory. The comparison is done on the name and is not case-sensitive.
      Parameters:
      category - The string name of the category
      Returns:
      The matching SoundCategory, null if none.