Record Class CosmeticState
java.lang.Object
java.lang.Record
dev.itsharshxd.zentrix.api.cosmetics.CosmeticState
- Record Components:
cosmetic- the cosmeticowned- whether the player owns it, permanently or for a limited timeunlocked- whether the player may use it: owning it, holding its permission, or, for a class or an addon's cosmetic, needing neitherselected- whether it is the player's stored choiceequipped- whether it is in effect for the playerexpiry- when a cosmetic owned for a limited time expires, or nullpurchasable- whether it is for sale and the player cannot use it yetaffordable- 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
ConstructorsConstructorDescriptionCosmeticState(@NotNull Cosmetic cosmetic, boolean owned, boolean unlocked, boolean selected, boolean equipped, @Nullable Instant expiry, boolean purchasable, boolean affordable) Creates an instance of aCosmeticStaterecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of theaffordablerecord component.booleanWhether the player could buy it now, as far as their last-read balance tells.booleancanUse()Whether the player may equip it.@NotNull Cosmeticcosmetic()Returns the value of thecosmeticrecord component.final booleanIndicates whether some other object is "equal to" this one.booleanequipped()Returns the value of theequippedrecord component.@Nullable Instantexpiry()Returns the value of theexpiryrecord component.When a cosmetic owned for a limited time expires; empty otherwise.final inthashCode()Returns a hash code value for this object.booleanowned()Returns the value of theownedrecord component.booleanReturns the value of thepurchasablerecord component.booleanselected()Returns the value of theselectedrecord component.final StringtoString()Returns a string representation of this record class.booleanunlocked()Returns the value of theunlockedrecord component.
-
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 aCosmeticStaterecord class.- Parameters:
cosmetic- the value for thecosmeticrecord componentowned- the value for theownedrecord componentunlocked- the value for theunlockedrecord componentselected- the value for theselectedrecord componentequipped- the value for theequippedrecord componentexpiry- the value for theexpiryrecord componentpurchasable- the value for thepurchasablerecord componentaffordable- the value for theaffordablerecord 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
When a cosmetic owned for a limited time expires; empty otherwise. -
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
cosmetic
Returns the value of thecosmeticrecord component.- Returns:
- the value of the
cosmeticrecord component
-
owned
public boolean owned()Returns the value of theownedrecord component.- Returns:
- the value of the
ownedrecord component
-
unlocked
public boolean unlocked()Returns the value of theunlockedrecord component.- Returns:
- the value of the
unlockedrecord component
-
selected
public boolean selected()Returns the value of theselectedrecord component.- Returns:
- the value of the
selectedrecord component
-
equipped
public boolean equipped()Returns the value of theequippedrecord component.- Returns:
- the value of the
equippedrecord component
-
expiry
Returns the value of theexpiryrecord component.- Returns:
- the value of the
expiryrecord component
-
purchasable
public boolean purchasable()Returns the value of thepurchasablerecord component.- Returns:
- the value of the
purchasablerecord component
-
affordable
public boolean affordable()Returns the value of theaffordablerecord component.- Returns:
- the value of the
affordablerecord component
-