Record Class Cooldown

java.lang.Object
java.lang.Record
net.flectone.pulse.model.value.Cooldown
Record Components:
enable - whether the cooldown is applied at all
duration - the wait between uses, in seconds

public record Cooldown(boolean enable, long duration) extends Record
How long a player must wait before triggering the same action again.
  • Field Summary

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

    Constructors
    Constructor
    Description
    Cooldown(boolean enable, long duration)
    Creates an instance of a Cooldown record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the value of the duration record component.
    boolean
    Returns the value of the enable record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    static Cooldown
    Reads a cooldown from its config representation.
    final int
    Returns a hash code value for this object.
    Writes this cooldown back to its config representation.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

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

    • DEFAULT

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

    • Cooldown

      public Cooldown(boolean enable, long duration)
      Creates an instance of a Cooldown record class.
      Parameters:
      enable - the value for the enable record component
      duration - the value for the duration record component
  • Method Details

    • fromJson

      public static Cooldown fromJson(Map<String,Object> map)
      Reads a cooldown from its config representation. A disabled cooldown collapses to DEFAULT, so the duration is only read when enabled.
      Parameters:
      map - the raw config values
      Returns:
      the parsed cooldown
    • toJson

      public Map<String,Object> toJson()
      Writes this cooldown back to its config representation. The duration is omitted while disabled to keep the file short.
      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. All components in this record class 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
    • duration

      public long duration()
      Returns the value of the duration record component.
      Returns:
      the value of the duration record component