Package dev.itsharshxd.zentrix.api.perk
Record Class PerkBoost
java.lang.Object
java.lang.Record
dev.itsharshxd.zentrix.api.perk.PerkBoost
- Record Components:
id- identifies the boost, for removing itperk- the built-in perk it boosts; null for a boost of an addon perk, seeperkKeyamount- added to a number perk; ignored by a toggleexpiresAt- when it endssource- who or what gave it, such as an administrator's name or a shop's IDperkKey- 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 Summary
ConstructorsConstructorDescriptionPerkBoost(@NotNull String id, @NotNull Perk perk, int amount, @NotNull Instant expiresAt, @NotNull String source) A boost of a built-in perk.PerkBoost(@NotNull String id, @Nullable Perk perk, int amount, @NotNull Instant expiresAt, @NotNull String source, @NotNull String perkKey) Creates an instance of aPerkBoostrecord class.PerkBoost(@NotNull String id, @NotNull String perkKey, int amount, @NotNull Instant expiresAt, @NotNull String source) A boost of any perk by its key. -
Method Summary
Modifier and TypeMethodDescriptionintamount()Returns the value of theamountrecord component.final booleanIndicates whether some other object is "equal to" this one.@NotNull InstantReturns the value of theexpiresAtrecord component.@NotNull DurationHow long the boost lasts from now; zero once it ended.final inthashCode()Returns a hash code value for this object.@NotNull Stringid()Returns the value of theidrecord component.booleanisActive()Whether the boost still applies.booleanWhether the boost is of an addon perk, whoseperk()is null.@Nullable Perkperk()Returns the value of theperkrecord component.@NotNull StringperkKey()Returns the value of theperkKeyrecord component.@NotNull Stringsource()Returns the value of thesourcerecord component.final StringtoString()Returns a string representation of this record class.
-
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 aPerkBoostrecord class.- Parameters:
id- the value for theidrecord componentperk- the value for theperkrecord componentamount- the value for theamountrecord componentexpiresAt- the value for theexpiresAtrecord componentsource- the value for thesourcerecord componentperkKey- the value for theperkKeyrecord 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, whoseperk()is null.- Since:
- 1.16.0
-
isActive
public boolean isActive()Whether the boost still applies. -
getRemaining
How long the boost lasts from now; zero once it ended. -
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 '=='. -
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
perk
Returns the value of theperkrecord component.- Returns:
- the value of the
perkrecord component
-
amount
public int amount()Returns the value of theamountrecord component.- Returns:
- the value of the
amountrecord component
-
expiresAt
Returns the value of theexpiresAtrecord component.- Returns:
- the value of the
expiresAtrecord component
-
source
Returns the value of thesourcerecord component.- Returns:
- the value of the
sourcerecord component
-
perkKey
Returns the value of theperkKeyrecord component.- Returns:
- the value of the
perkKeyrecord component
-