Record Class CosmeticOwnership
java.lang.Object
java.lang.Record
dev.itsharshxd.zentrix.api.cosmetics.CosmeticOwnership
- Record Components:
category- the built-in category, or null for an addon's typeowned- the owned cosmetic IDs, in the order they were grantedselected- the chosen cosmetic's ID, or null for the server's defaultexpiries- when each timed cosmetic expires, by ID; empty when every one is permanenttype- the type, built-in or an addon's (since 1.11.0)
public record CosmeticOwnership(@Nullable CosmeticCategory category, @NotNull Set<String> owned, @Nullable String selected, @NotNull Map<String,Instant> expiries, @NotNull CosmeticTypeKey type)
extends Record
What one player owns and chose in one cosmetic category. A snapshot.
Owning a cosmetic an administrator later deleted is kept, and counts again once a cosmetic with that ID exists.
A cosmetic granted for a limited time has an entry in expiries; one without an entry
is owned permanently. Expired cosmetics are never listed: Zentrix removes them as they expire,
also for players who were offline at the time.
Since 1.11.0 ownership also describes an addon's type, whose
category is null. Ownership read through the 1.8.0 methods, which take a
CosmeticCategory, always has one.
- Since:
- 1.8.0
-
Constructor Summary
ConstructorsConstructorDescriptionCosmeticOwnership(@NotNull CosmeticCategory category, @NotNull Set<String> owned, @Nullable String selected) Ownership without timed cosmetics, as API 1.8.0 described it.CosmeticOwnership(@NotNull CosmeticCategory category, @NotNull Set<String> owned, @Nullable String selected, @NotNull Map<String, Instant> expiries) Ownership of a built-in category, as API 1.9.0 described it.CosmeticOwnership(@NotNull CosmeticTypeKey type, @NotNull Set<String> owned, @Nullable String selected, @NotNull Map<String, Instant> expiries) Ownership of any type, built-in or an addon's.CosmeticOwnership(@Nullable CosmeticCategory category, @NotNull Set<String> owned, @Nullable String selected, @NotNull Map<String, Instant> expiries, @NotNull CosmeticTypeKey type) Creates an instance of aCosmeticOwnershiprecord class. -
Method Summary
Modifier and TypeMethodDescription@Nullable CosmeticCategorycategory()Returns the value of thecategoryrecord component.static @NotNull CosmeticOwnershipempty(@NotNull CosmeticTypeKey type) Nothing owned or chosen in a type.final booleanIndicates whether some other object is "equal to" this one.expiries()Returns the value of theexpiriesrecord component.The chosen cosmetic while the player still owns it; empty means the server's default.When a timed cosmetic expires.getRemaining(@NotNull String id) How long the player keeps a timed cosmetic from now.final inthashCode()Returns a hash code value for this object.booleanWhether a cosmetic is owned for a limited time.owned()Returns the value of theownedrecord component.booleanWhether the player owns a cosmetic.@Nullable Stringselected()Returns the value of theselectedrecord component.final StringtoString()Returns a string representation of this record class.@NotNull CosmeticTypeKeytype()Returns the value of thetyperecord component.
-
Constructor Details
-
CosmeticOwnership
public CosmeticOwnership(@Nullable @Nullable CosmeticCategory category, @NotNull @NotNull Set<String> owned, @Nullable @Nullable String selected, @NotNull @NotNull Map<String, Instant> expiries, @NotNull @NotNull CosmeticTypeKey type) Creates an instance of aCosmeticOwnershiprecord class. -
CosmeticOwnership
public CosmeticOwnership(@NotNull @NotNull CosmeticCategory category, @NotNull @NotNull Set<String> owned, @Nullable @Nullable String selected, @NotNull @NotNull Map<String, Instant> expiries) Ownership of a built-in category, as API 1.9.0 described it. -
CosmeticOwnership
public CosmeticOwnership(@NotNull @NotNull CosmeticCategory category, @NotNull @NotNull Set<String> owned, @Nullable @Nullable String selected) Ownership without timed cosmetics, as API 1.8.0 described it. -
CosmeticOwnership
public CosmeticOwnership(@NotNull @NotNull CosmeticTypeKey type, @NotNull @NotNull Set<String> owned, @Nullable @Nullable String selected, @NotNull @NotNull Map<String, Instant> expiries) Ownership of any type, built-in or an addon's.- Since:
- 1.11.0
-
-
Method Details
-
empty
Nothing owned or chosen in a type.- Since:
- 1.11.0
-
owns
Whether the player owns a cosmetic. -
getEffectiveSelection
The chosen cosmetic while the player still owns it; empty means the server's default. -
getExpiry
When a timed cosmetic expires.- Returns:
- empty when the cosmetic is owned permanently or not owned at all
- Since:
- 1.9.0
-
isTimed
Whether a cosmetic is owned for a limited time.- Since:
- 1.9.0
-
getRemaining
How long the player keeps a timed cosmetic from now.- Returns:
- empty when the cosmetic is owned permanently or not owned at all; zero once it is due
- Since:
- 1.9.0
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
category
Returns the value of thecategoryrecord component.- Returns:
- the value of the
categoryrecord component
-
owned
Returns the value of theownedrecord component.- Returns:
- the value of the
ownedrecord component
-
selected
Returns the value of theselectedrecord component.- Returns:
- the value of the
selectedrecord component
-
expiries
Returns the value of theexpiriesrecord component.- Returns:
- the value of the
expiriesrecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-