Record Class Sound

java.lang.Object
java.lang.Record
net.flectone.pulse.model.value.Sound
Record Components:
enable - whether the sound is played at all
volume - the playback volume
pitch - the playback pitch
category - the mixer category the sound belongs to
name - the namespaced sound id

public record Sound(boolean enable, float volume, float pitch, String category, String name) extends Record
A sound played alongside a message.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Sound
    A disabled sound, which every disabled entry collapses to.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Sound(boolean enable, float volume, float pitch, String category, String name)
    Creates an instance of a Sound record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the category record component.
    boolean
    Returns the value of the enable record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    static Sound
    Reads a sound from its config representation.
    final int
    Returns a hash code value for this object.
    Returns the value of the name record component.
    float
    Returns the value of the pitch record component.
    Writes this sound back to its config representation, omitting the details while disabled.
    final String
    Returns a string representation of this record class.
    float
    Returns the value of the volume record component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • DEFAULT

      public static final Sound DEFAULT
      A disabled sound, which every disabled entry collapses to.
  • Constructor Details

    • Sound

      public Sound(boolean enable, float volume, float pitch, String category, String name)
      Creates an instance of a Sound record class.
      Parameters:
      enable - the value for the enable record component
      volume - the value for the volume record component
      pitch - the value for the pitch record component
      category - the value for the category record component
      name - the value for the name record component
  • Method Details

    • fromJson

      public static Sound fromJson(Map<String,Object> map)
      Reads a sound from its config representation. A disabled sound collapses to DEFAULT, so the rest of the keys are only read when enabled.
      Parameters:
      map - the raw config values
      Returns:
      the parsed sound
    • toJson

      public Map<String,Object> toJson()
      Writes this sound back to its config representation, omitting the details while disabled.
      Returns:
      the config values
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • enable

      public boolean enable()
      Returns the value of the enable record component.
      Returns:
      the value of the enable record component
    • volume

      public float volume()
      Returns the value of the volume record component.
      Returns:
      the value of the volume record component
    • pitch

      public float pitch()
      Returns the value of the pitch record component.
      Returns:
      the value of the pitch record component
    • category

      public String category()
      Returns the value of the category record component.
      Returns:
      the value of the category record component
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component