Record Class Cosmetic

java.lang.Object
java.lang.Record
dev.itsharshxd.zentrix.api.cosmetics.Cosmetic
Record Components:
type - the type it belongs to
id - the stable ID ownership is stored under
name - the display name, in Zentrix's colour format
icon - the icon menus show it with; a copy
lore - the description lines, in Zentrix's colour format
rarity - the rarity label, in Zentrix's colour format, or null for none
permission - the permission that unlocks it without owning it, or null for none
price - what it costs in Zentrix's currency, or null when it is not for sale
source - the name of the plugin that provides it, Zentrix for built-in ones

public record Cosmetic(@NotNull CosmeticTypeKey type, @NotNull String id, @NotNull String name, @NotNull org.bukkit.inventory.ItemStack icon, @NotNull List<String> lore, @Nullable String rarity, @Nullable String permission, @Nullable Double price, @NotNull String source) extends Record
One cosmetic as menus show it, of a built-in category or an addon's type. A snapshot: later edits do not change it.

Zentrix's own cosmetics have no rarity or price: they are granted, or unlocked by their permission. An addon's carry whatever its CosmeticDefinition sets.

Since:
1.11.0
  • Constructor Details

    • Cosmetic

      public Cosmetic(@NotNull @NotNull CosmeticTypeKey type, @NotNull @NotNull String id, @NotNull @NotNull String name, @NotNull @NotNull org.bukkit.inventory.ItemStack icon, @NotNull @NotNull List<String> lore, @Nullable @Nullable String rarity, @Nullable @Nullable String permission, @Nullable @Nullable Double price, @NotNull @NotNull String source)
      Creates an instance of a Cosmetic record class.
      Parameters:
      type - the value for the type record component
      id - the value for the id record component
      name - the value for the name record component
      icon - the value for the icon record component
      lore - the value for the lore record component
      rarity - the value for the rarity record component
      permission - the value for the permission record component
      price - the value for the price record component
      source - the value for the source record component
  • Method Details

    • icon

      @NotNull public @NotNull org.bukkit.inventory.ItemStack icon()
      A copy of the icon.
    • getRarity

      @NotNull public @NotNull Optional<String> getRarity()
      The rarity label, when there is one.
    • getPermission

      @NotNull public @NotNull Optional<String> getPermission()
      The permission that unlocks it, when there is one.
    • getPrice

      @NotNull public @NotNull OptionalDouble getPrice()
      What it costs; empty when it is not for sale.
    • isForSale

      public boolean isForSale()
      Whether it can be bought with Zentrix's currency.
    • isBuiltIn

      public boolean isBuiltIn()
      Whether Zentrix itself provides it.
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • type

      @NotNull public @NotNull CosmeticTypeKey type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • id

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

      @NotNull public @NotNull String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • lore

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

      @Nullable public @Nullable String rarity()
      Returns the value of the rarity record component.
      Returns:
      the value of the rarity record component
    • permission

      @Nullable public @Nullable String permission()
      Returns the value of the permission record component.
      Returns:
      the value of the permission record component
    • price

      @Nullable public @Nullable Double price()
      Returns the value of the price record component.
      Returns:
      the value of the price record component
    • source

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