Record Class CosmeticState

java.lang.Object
java.lang.Record
dev.itsharshxd.zentrix.api.cosmetics.CosmeticState
Record Components:
cosmetic - the cosmetic
owned - whether the player owns it, permanently or for a limited time
unlocked - whether the player may use it: owning it, holding its permission, or, for a class or an addon's cosmetic, needing neither
selected - whether it is the player's stored choice
equipped - whether it is in effect for the player
expiry - when a cosmetic owned for a limited time expires, or null
purchasable - whether it is for sale and the player cannot use it yet
affordable - whether it is purchasable and the player's balance, as last read, covers it

public record CosmeticState(@NotNull Cosmetic cosmetic, boolean owned, boolean unlocked, boolean selected, boolean equipped, @Nullable Instant expiry, boolean purchasable, boolean affordable) extends Record
Where one online player stands with one cosmetic, as last read. A snapshot.

Selected is the player's stored choice; equipped is what is in effect: the choice while the player can still use it, otherwise the type's default. A player who chose nothing has the default equipped without having selected it.

Since:
1.11.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    CosmeticState(@NotNull Cosmetic cosmetic, boolean owned, boolean unlocked, boolean selected, boolean equipped, @Nullable Instant expiry, boolean purchasable, boolean affordable)
    Creates an instance of a CosmeticState record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns the value of the affordable record component.
    boolean
    Whether the player could buy it now, as far as their last-read balance tells.
    boolean
    Whether the player may equip it.
    @NotNull Cosmetic
    Returns the value of the cosmetic record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    boolean
    Returns the value of the equipped record component.
    @Nullable Instant
    Returns the value of the expiry record component.
    @NotNull Optional<Instant>
    When a cosmetic owned for a limited time expires; empty otherwise.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the owned record component.
    boolean
    Returns the value of the purchasable record component.
    boolean
    Returns the value of the selected record component.
    final String
    Returns a string representation of this record class.
    boolean
    Returns the value of the unlocked record component.

    Methods inherited from class java.lang.Object

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

    • CosmeticState

      public CosmeticState(@NotNull @NotNull Cosmetic cosmetic, boolean owned, boolean unlocked, boolean selected, boolean equipped, @Nullable @Nullable Instant expiry, boolean purchasable, boolean affordable)
      Creates an instance of a CosmeticState record class.
      Parameters:
      cosmetic - the value for the cosmetic record component
      owned - the value for the owned record component
      unlocked - the value for the unlocked record component
      selected - the value for the selected record component
      equipped - the value for the equipped record component
      expiry - the value for the expiry record component
      purchasable - the value for the purchasable record component
      affordable - the value for the affordable record component
  • Method Details

    • canUse

      public boolean canUse()
      Whether the player may equip it.
    • canPurchase

      public boolean canPurchase()
      Whether the player could buy it now, as far as their last-read balance tells.
    • getExpiry

      @NotNull public @NotNull Optional<Instant> getExpiry()
      When a cosmetic owned for a limited time expires; empty otherwise.
    • 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 '=='.
      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.
    • cosmetic

      @NotNull public @NotNull Cosmetic cosmetic()
      Returns the value of the cosmetic record component.
      Returns:
      the value of the cosmetic record component
    • owned

      public boolean owned()
      Returns the value of the owned record component.
      Returns:
      the value of the owned record component
    • unlocked

      public boolean unlocked()
      Returns the value of the unlocked record component.
      Returns:
      the value of the unlocked record component
    • selected

      public boolean selected()
      Returns the value of the selected record component.
      Returns:
      the value of the selected record component
    • equipped

      public boolean equipped()
      Returns the value of the equipped record component.
      Returns:
      the value of the equipped record component
    • expiry

      @Nullable public @Nullable Instant expiry()
      Returns the value of the expiry record component.
      Returns:
      the value of the expiry record component
    • purchasable

      public boolean purchasable()
      Returns the value of the purchasable record component.
      Returns:
      the value of the purchasable record component
    • affordable

      public boolean affordable()
      Returns the value of the affordable record component.
      Returns:
      the value of the affordable record component