Class SoundEventSelection

java.lang.Object
me.gamercoder215.starcosmetics.api.player.SoundEventSelection
All Implemented Interfaces:
ConfigurationSerializable

public final class SoundEventSelection extends Object implements ConfigurationSerializable
Represents an entry in a player's configuration for a sound to be played on any events in AVAILABLE_EVENTS.
  • Field Details

    • AVAILABLE_EVENTS

      public static final List<Class<? extends Event>> AVAILABLE_EVENTS

      A List of all Available Events to be used in a SoundEventSelection.

      This list is mutable; Integration for custom events is supported.
  • Method Details

    • of

      public static SoundEventSelection of(@NotNull @NotNull Class<? extends Event> event, @NotNull @NotNull Sound sound, float volume, float pitch, @NotNull @NotNull OfflinePlayer player, @NotNull @NotNull Date date)
      Creates a new instance.
      Parameters:
      event - The event to play the sound on.
      sound - The sound to play.
      volume - The volume of the sound.
      pitch - The pitch of the sound.
      player - The Player that owns this SoundEventSelection.
      date - The Timestamp that this sound was created at.
      Returns:
      Constructed SoundEventSelection
    • isValid

      public static boolean isValid(@NotNull @NotNull Class<? extends Event> event)
      Checks whether this event is valid to listen to.
      Parameters:
      event - The event to check.
      Returns:
      true if valid, false otherwise
    • getPlayer

      @NotNull public @NotNull OfflinePlayer getPlayer()
      Fetches the player that this SoundEventSelection belongs to.
      Returns:
      OfflinePlayer
    • getSound

      @NotNull public @NotNull Sound getSound()
      Fetches the Sound that this SoundEventSelection will play.
      Returns:
      Sound
    • getTimestamp

      @NotNull public @NotNull Date getTimestamp()
      Fetches the Date this SoundEventSelection was created.
      Returns:
      Timestamp of Creation
    • getVolume

      public float getVolume()
      Fetches the volume of the sound.
      Returns:
      Sound Volume
    • play

      public void play(@NotNull @NotNull Location loc)
      Plays this sound with its volume and pitch.
      Parameters:
      loc - The location to play the sound at.
    • play

      public void play(@NotNull @NotNull Entity en)
      Plays this sound with its volume and pitch.
      Parameters:
      en - The entity to play the sound at.
    • getPitch

      public float getPitch()
      Fetches the pitch of the sound.
      Returns:
      Sound Pitch
    • getEvent

      @NotNull public @NotNull Class<? extends Event> getEvent()
      Fetches the Event that this SoundEventSelection is listening for.
      Returns:
      Class of the Event
    • cloneTo

      @NotNull public @NotNull SoundEventSelection cloneTo(@NotNull @NotNull OfflinePlayer player)
      Clones this SoundEventSelection with a new owner.
      Parameters:
      player - The new owner of this SoundEventSelection.
      Returns:
      Cloned SoundEventSelection
    • cloneTo

      @NotNull public @NotNull SoundEventSelection cloneTo(@NotNull @NotNull Sound s, float volume, float pitch)
      Clones this SoundEventSelection with a new Sound, pitch, and volume.
      Parameters:
      s - The new Sound to play.
      volume - The new volume of the sound.
      pitch - The new pitch of the sound.
      Returns:
      Cloned SoundEventSelection
    • cloneTo

      @NotNull public @NotNull SoundEventSelection cloneTo(@NotNull @NotNull Sound s)
      Clones this SoundEventSelection with a new Sound.
      Parameters:
      s - The new Sound to play.
      Returns:
      Cloned SoundEventSelection
    • cloneTo

      @NotNull public @NotNull SoundEventSelection cloneTo(@NotNull @NotNull Class<? extends Event> e)
      Clones this SoundEventSelection with a new Event.
      Parameters:
      e - The new Event to listen for.
      Returns:
      Cloned SoundEventSelection
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equalsIgnorePlayer

      public boolean equalsIgnorePlayer(@NotNull @NotNull SoundEventSelection other)
      Whether this SoundEventSelection equals another SoundEventSelection, ignoring the player.
      Parameters:
      other - The other SoundEventSelection
      Returns:
      Whether the two SoundEventSelections are equal without the player
    • deserialize

      @Nullable public static @Nullable SoundEventSelection deserialize(@NotNull @NotNull Map<String,Object> serial)
      Deserializes a Map into a SoundEventSelection.
      Parameters:
      serial - Serialization from serialize()
      Returns:
      Deserialized SoundEventSelection
    • serialize

      public Map<String,Object> serialize()
      Specified by:
      serialize in interface ConfigurationSerializable
    • builder

      @NotNull public static @NotNull SoundEventSelection.Builder builder()
      Fetches the SoundEventSelection Builder.
      Returns:
      SoundEventSelection Builder