Package dev.itsharshxd.zentrix.api.perk
Class PerkDefinition
java.lang.Object
dev.itsharshxd.zentrix.api.perk.PerkDefinition
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
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe value of aPerk.Type.NUMBERperk that means unlimited, where it is supported. -
Method Summary
Modifier and TypeMethodDescriptionbooleanThe built-in perk this defines, or empty for an addon perk.intThe server-wide default of a number perk, for players whose tiers leave it out; may beUNLIMITED.What the perk does, one line each, as menus show it.@NotNull StringThe name players read, with its color codes.@NotNull org.bukkit.MaterialgetIcon()The item the perk wears in menus.@NotNull StringgetKey()The key a tier sets the perk under inperks.yml, such asparty.max-size.intThe highest a number perk can be, boosts included.intThe lowest a number perk can be, boosts included.getType()inthashCode()booleanisAddon()Whether this is an addon perk rather than a built-in one.booleanThe server-wide default of a toggle perk.booleanisUnlimited(int value) Whether a value of this number perk means unlimited.static booleanisValidAddonKey(@Nullable String key) Whether text can be an addon perk's key: lowercase words joined by one to three dots, such asmyaddon.kit-slots.static @NotNull PerkDefinition.BuilderStarts aPerk.Type.NUMBERperk under an addon key such asmyaddon.kit-slots.booleanstatic @NotNull PerkDefinition.BuilderStarts aPerk.Type.TOGGLEperk under an addon key such asmyaddon.fly.toString()
-
Field Details
-
UNLIMITED
public static final int UNLIMITEDThe value of aPerk.Type.NUMBERperk that means unlimited, where it is supported.- See Also:
-
-
Method Details
-
number
Starts aPerk.Type.NUMBERperk under an addon key such asmyaddon.kit-slots. -
toggle
Starts aPerk.Type.TOGGLEperk under an addon key such asmyaddon.fly. -
isValidAddonKey
Whether text can be an addon perk's key: lowercase words joined by one to three dots, such asmyaddon.kit-slots. A key also has to be free of built-in perks to be registered. -
getKey
The key a tier sets the perk under inperks.yml, such asparty.max-size. -
getType
-
getDefaultNumber
public int getDefaultNumber()The server-wide default of a number perk, for players whose tiers leave it out; may beUNLIMITED. For a built-in perk it is the default when the definition was taken, since several come fromsettings.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() -
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
What the perk does, one line each, as menus show it. -
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
-
hashCode
public int hashCode() -
toString
-