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 type
owned - the owned cosmetic IDs, in the order they were granted
selected - the chosen cosmetic's ID, or null for the server's default
expiries - when each timed cosmetic expires, by ID; empty when every one is permanent
type - 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 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 a CosmeticOwnership record class.
      Parameters:
      category - the value for the category record component
      owned - the value for the owned record component
      selected - the value for the selected record component
      expiries - the value for the expiries record component
      type - the value for the type record component
    • 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

      @NotNull public static @NotNull CosmeticOwnership empty(@NotNull @NotNull CosmeticTypeKey type)
      Nothing owned or chosen in a type.
      Since:
      1.11.0
    • owns

      public boolean owns(@NotNull @NotNull String id)
      Whether the player owns a cosmetic.
    • getEffectiveSelection

      @NotNull public @NotNull Optional<String> getEffectiveSelection()
      The chosen cosmetic while the player still owns it; empty means the server's default.
    • getExpiry

      @NotNull public @NotNull Optional<Instant> getExpiry(@NotNull @NotNull String id)
      When a timed cosmetic expires.
      Returns:
      empty when the cosmetic is owned permanently or not owned at all
      Since:
      1.9.0
    • isTimed

      public boolean isTimed(@NotNull @NotNull String id)
      Whether a cosmetic is owned for a limited time.
      Since:
      1.9.0
    • getRemaining

      @NotNull public @NotNull Optional<Duration> getRemaining(@NotNull @NotNull String id)
      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

      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 Objects::equals(Object,Object).
      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.
    • category

      @Nullable public @Nullable CosmeticCategory category()
      Returns the value of the category record component.
      Returns:
      the value of the category record component
    • owned

      @NotNull public @NotNull Set<String> owned()
      Returns the value of the owned record component.
      Returns:
      the value of the owned record component
    • selected

      @Nullable public @Nullable String selected()
      Returns the value of the selected record component.
      Returns:
      the value of the selected record component
    • expiries

      @NotNull public @NotNull Map<String,Instant> expiries()
      Returns the value of the expiries record component.
      Returns:
      the value of the expiries record component
    • type

      @NotNull public @NotNull CosmeticTypeKey type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component