Record Class PerkBoost

java.lang.Object
java.lang.Record
dev.itsharshxd.zentrix.api.perk.PerkBoost
Record Components:
id - identifies the boost, for removing it
perk - the built-in perk it boosts; null for a boost of an addon perk, see perkKey
amount - added to a number perk; ignored by a toggle
expiresAt - when it ends
source - who or what gave it, such as an administrator's name or a shop's ID
perkKey - the key of the perk it boosts, built-in or addon (since 1.16.0)

public record PerkBoost(@NotNull String id, @Nullable Perk perk, int amount, @NotNull Instant expiresAt, @NotNull String source, @NotNull String perkKey) extends Record
A temporary perk boost given to one player, such as one extra host slot for 24 hours. A snapshot.

A Perk.Type.NUMBER boost adds amount to the player's value, on top of their tier; several boosts of one perk add up. A Perk.Type.TOGGLE boost allows the perk while it lasts. A boost ends on its own when it expires, on every server sharing the database.

Since:
1.9.0
  • Constructor Details

    • PerkBoost

      public PerkBoost(@NotNull @NotNull String id, @Nullable @Nullable Perk perk, int amount, @NotNull @NotNull Instant expiresAt, @NotNull @NotNull String source, @NotNull @NotNull String perkKey)
      Creates an instance of a PerkBoost record class.
      Parameters:
      id - the value for the id record component
      perk - the value for the perk record component
      amount - the value for the amount record component
      expiresAt - the value for the expiresAt record component
      source - the value for the source record component
      perkKey - the value for the perkKey record component
    • PerkBoost

      public PerkBoost(@NotNull @NotNull String id, @NotNull @NotNull Perk perk, int amount, @NotNull @NotNull Instant expiresAt, @NotNull @NotNull String source)
      A boost of a built-in perk.
    • PerkBoost

      public PerkBoost(@NotNull @NotNull String id, @NotNull @NotNull String perkKey, int amount, @NotNull @NotNull Instant expiresAt, @NotNull @NotNull String source)
      A boost of any perk by its key.
      Since:
      1.16.0
  • Method Details

    • isAddonPerk

      public boolean isAddonPerk()
      Whether the boost is of an addon perk, whose perk() is null.
      Since:
      1.16.0
    • isActive

      public boolean isActive()
      Whether the boost still applies.
    • getRemaining

      @NotNull public @NotNull Duration getRemaining()
      How long the boost lasts from now; zero once it ended.
    • 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.
    • id

      @NotNull public @NotNull String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • perk

      @Nullable public @Nullable Perk perk()
      Returns the value of the perk record component.
      Returns:
      the value of the perk record component
    • amount

      public int amount()
      Returns the value of the amount record component.
      Returns:
      the value of the amount record component
    • expiresAt

      @NotNull public @NotNull Instant expiresAt()
      Returns the value of the expiresAt record component.
      Returns:
      the value of the expiresAt record component
    • source

      @NotNull public @NotNull String source()
      Returns the value of the source record component.
      Returns:
      the value of the source record component
    • perkKey

      @NotNull public @NotNull String perkKey()
      Returns the value of the perkKey record component.
      Returns:
      the value of the perkKey record component