Class PerkDefinition

java.lang.Object
dev.itsharshxd.zentrix.api.perk.PerkDefinition

public final class PerkDefinition extends Object
Describes a perk: its key, the kind of value it holds, its server-wide default and bounds, and how menus show it.

Every built-in Perk has a definition, and addons register their own with PerkService.registerPerk(org.bukkit.plugin.Plugin, dev.itsharshxd.zentrix.api.perk.PerkDefinition). Both resolve through the same path: tiers in perks.yml set a value under the perk's key, boosts add to it, and /perks, the tier editor and placeholders show it.


 PerkDefinition kits = PerkDefinition.number("myaddon.kit-slots")
         .defaultValue(1).minimum(0).unlimited(true)
         .displayName("&bKit Slots").icon(Material.CHEST)
         .description("How many kits a player may save.")
         .build();
 ZentrixAPI.get().getPerkService().registerPerk(plugin, kits);
 

Two definitions are equal when their keys are.

Since:
1.16.0
  • Field Details

  • Method Details

    • number

      @NotNull public static @NotNull PerkDefinition.Builder number(@NotNull @NotNull String key)
      Starts a Perk.Type.NUMBER perk under an addon key such as myaddon.kit-slots.
    • toggle

      @NotNull public static @NotNull PerkDefinition.Builder toggle(@NotNull @NotNull String key)
      Starts a Perk.Type.TOGGLE perk under an addon key such as myaddon.fly.
    • isValidAddonKey

      public static boolean isValidAddonKey(@Nullable @Nullable String key)
      Whether text can be an addon perk's key: lowercase words joined by one to three dots, such as myaddon.kit-slots. A key also has to be free of built-in perks to be registered.
    • getKey

      @NotNull public @NotNull String getKey()
      The key a tier sets the perk under in perks.yml, such as party.max-size.
    • getType

      @NotNull public Perk.Type getType()
    • getDefaultNumber

      public int getDefaultNumber()
      The server-wide default of a number perk, for players whose tiers leave it out; may be UNLIMITED. For a built-in perk it is the default when the definition was taken, since several come from settings.yml.
    • isAllowedByDefault

      public boolean isAllowedByDefault()
      The server-wide default of a toggle perk.
    • getMinimum

      public int getMinimum()
      The lowest a number perk can be, boosts included.
    • getMaximum

      public int getMaximum()
      The highest a number perk can be, boosts included.
    • supportsUnlimited

      public boolean supportsUnlimited()
      Whether a number perk can be UNLIMITED, written -1 in perks.yml.
    • getDisplayName

      @NotNull public @NotNull String getDisplayName()
      The name players read, with its color codes.
    • getIcon

      @NotNull public @NotNull org.bukkit.Material getIcon()
      The item the perk wears in menus.
    • getDescription

      @NotNull public @NotNull List<String> getDescription()
      What the perk does, one line each, as menus show it.
    • getBuiltIn

      @NotNull public @NotNull Optional<Perk> getBuiltIn()
      The built-in perk this defines, or empty for an addon perk.
    • isAddon

      public boolean isAddon()
      Whether this is an addon perk rather than a built-in one.
    • isUnlimited

      public boolean isUnlimited(int value)
      Whether a value of this number perk means unlimited.
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object