Record Class PerkTier

java.lang.Object
java.lang.Record
dev.itsharshxd.zentrix.api.perk.PerkTier
Record Components:
id - the tier's key in perks.yml
displayName - the name shown to players, with its color codes
permission - the node that puts a player in the tier
priority - higher wins when a player holds several tiers' permissions
numbers - the Perk.Type.NUMBER built-in perks the tier sets or inherits
toggles - the Perk.Type.TOGGLE built-in perks the tier sets or inherits
parent - the ID of the tier it inherits from, or null (since 1.16.0)
icon - the item it wears in menus, or null for the default (since 1.16.0)
description - lines describing it in menus, with color codes (since 1.16.0)
addonNumbers - the number addon perks it sets or inherits, by key (since 1.16.0)
addonToggles - the toggle addon perks it sets or inherits, by key (since 1.16.0)

public record PerkTier(@NotNull String id, @NotNull String displayName, @NotNull String permission, int priority, @NotNull Map<Perk,Integer> numbers, @NotNull Map<Perk,Boolean> toggles, @Nullable String parent, @Nullable org.bukkit.Material icon, @NotNull List<String> description, @NotNull Map<String,Integer> addonNumbers, @NotNull Map<String,Boolean> addonToggles) extends Record
One named tier of perks.yml, such as vip. A snapshot.

A player belongs to the enabled tier with the highest priority whose permission they hold. A tier may inherit from a parent tier: each value comes from the tier itself, then up its parent chain, and only then from the server-wide default. The values here are the effective ones, inherited values included; a perk none of them sets follows the server-wide default.

A number value of PerkDefinition.UNLIMITED (-1) means unlimited, for perks that support it.

Since:
1.9.0
  • Constructor Details

    • PerkTier

      public PerkTier(@NotNull @NotNull String id, @NotNull @NotNull String displayName, @NotNull @NotNull String permission, int priority, @NotNull @NotNull Map<Perk,Integer> numbers, @NotNull @NotNull Map<Perk,Boolean> toggles, @Nullable @Nullable String parent, @Nullable @Nullable org.bukkit.Material icon, @NotNull @NotNull List<String> description, @NotNull @NotNull Map<String,Integer> addonNumbers, @NotNull @NotNull Map<String,Boolean> addonToggles)
      Creates an instance of a PerkTier record class.
      Parameters:
      id - the value for the id record component
      displayName - the value for the displayName record component
      permission - the value for the permission record component
      priority - the value for the priority record component
      numbers - the value for the numbers record component
      toggles - the value for the toggles record component
      parent - the value for the parent record component
      icon - the value for the icon record component
      description - the value for the description record component
      addonNumbers - the value for the addonNumbers record component
      addonToggles - the value for the addonToggles record component
    • PerkTier

      public PerkTier(@NotNull @NotNull String id, @NotNull @NotNull String displayName, @NotNull @NotNull String permission, int priority, @NotNull @NotNull Map<Perk,Integer> numbers, @NotNull @NotNull Map<Perk,Boolean> toggles)
      A tier without a parent, icon, description or addon perks.
  • Method Details

    • sets

      public boolean sets(@NotNull @NotNull Perk perk)
      Whether the tier sets or inherits a perk rather than leaving it to the server-wide default.
    • sets

      public boolean sets(@NotNull @NotNull String perkKey)
      Whether the tier sets or inherits a perk, built-in or addon, by its key.
      Since:
      1.16.0
    • getNumber

      @NotNull public @NotNull OptionalInt getNumber(@NotNull @NotNull Perk perk)
      The number the tier sets for a Perk.Type.NUMBER perk, if it sets one; PerkDefinition.UNLIMITED when unlimited.
    • getNumber

      @NotNull public @NotNull OptionalInt getNumber(@NotNull @NotNull String perkKey)
      The number the tier sets for a number perk, built-in or addon, by its key.
      Since:
      1.16.0
    • getToggle

      @NotNull public @NotNull Optional<Boolean> getToggle(@NotNull @NotNull Perk perk)
      Whether the tier allows a Perk.Type.TOGGLE perk, if it sets it.
    • getToggle

      @NotNull public @NotNull Optional<Boolean> getToggle(@NotNull @NotNull String perkKey)
      Whether the tier allows a toggle perk, built-in or addon, by its key, if it sets it.
      Since:
      1.16.0
    • getParent

      @NotNull public @NotNull Optional<String> getParent()
      The parent tier's ID, when the tier inherits from one.
      Since:
      1.16.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. 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
    • displayName

      @NotNull public @NotNull String displayName()
      Returns the value of the displayName record component.
      Returns:
      the value of the displayName record component
    • permission

      @NotNull public @NotNull String permission()
      Returns the value of the permission record component.
      Returns:
      the value of the permission record component
    • priority

      public int priority()
      Returns the value of the priority record component.
      Returns:
      the value of the priority record component
    • numbers

      @NotNull public @NotNull Map<Perk,Integer> numbers()
      Returns the value of the numbers record component.
      Returns:
      the value of the numbers record component
    • toggles

      @NotNull public @NotNull Map<Perk,Boolean> toggles()
      Returns the value of the toggles record component.
      Returns:
      the value of the toggles record component
    • parent

      @Nullable public @Nullable String parent()
      Returns the value of the parent record component.
      Returns:
      the value of the parent record component
    • icon

      @Nullable public @Nullable org.bukkit.Material icon()
      Returns the value of the icon record component.
      Returns:
      the value of the icon record component
    • description

      @NotNull public @NotNull List<String> description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component
    • addonNumbers

      @NotNull public @NotNull Map<String,Integer> addonNumbers()
      Returns the value of the addonNumbers record component.
      Returns:
      the value of the addonNumbers record component
    • addonToggles

      @NotNull public @NotNull Map<String,Boolean> addonToggles()
      Returns the value of the addonToggles record component.
      Returns:
      the value of the addonToggles record component