Record Class CosmeticTypeKey

java.lang.Object
java.lang.Record
dev.itsharshxd.zentrix.api.cosmetics.CosmeticTypeKey
Record Components:
namespace - who defines the type: zentrix, or the addon's namespace
key - the type within its namespace

public record CosmeticTypeKey(@NotNull String namespace, @NotNull String key) extends Record
Names a cosmetic type: one of Zentrix's own categories, under the zentrix namespace, or one an addon registered, under the addon's namespace. Written namespace:key, such as zentrix:gliders or myhats:hats.

Both parts use a-z, 0-9, _ and -. An addon's cosmetics are stored under its key, so keep it stable across versions.

Since:
1.11.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The namespace of Zentrix's own categories.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CosmeticTypeKey(@NotNull String namespace, @NotNull String key)
    Creates an instance of a CosmeticTypeKey record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull String
    The key as namespace:key.
    final boolean
    Indicates whether some other object is "equal to" this one.
    The built-in category this names; empty for an addon's type.
    final int
    Returns a hash code value for this object.
    boolean
    Whether this names one of Zentrix's own categories.
    @NotNull String
    key()
    Returns the value of the key record component.
    @NotNull String
    Returns the value of the namespace record component.
    static @NotNull String
    namespaceOf(@NotNull org.bukkit.plugin.Plugin plugin)
    The namespace of(Plugin, String) gives a plugin's types.
    static @NotNull CosmeticTypeKey
    of(@NotNull CosmeticCategory category)
    The key of one of Zentrix's own categories.
    static @NotNull CosmeticTypeKey
    of(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull String key)
    A key in a plugin's own namespace: its name in lowercase, with every character outside a-z, 0-9, _ and - replaced by _.
    static @NotNull Optional<CosmeticTypeKey>
    parse(@Nullable String text)
    Reads a key written as namespace:key, ignoring case.
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • CosmeticTypeKey

      public CosmeticTypeKey(@NotNull @NotNull String namespace, @NotNull @NotNull String key)
      Creates an instance of a CosmeticTypeKey record class.
      Parameters:
      namespace - the value for the namespace record component
      key - the value for the key record component
  • Method Details

    • of

      @NotNull public static @NotNull CosmeticTypeKey of(@NotNull @NotNull CosmeticCategory category)
      The key of one of Zentrix's own categories.
    • of

      @NotNull public static @NotNull CosmeticTypeKey of(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull String key)
      A key in a plugin's own namespace: its name in lowercase, with every character outside a-z, 0-9, _ and - replaced by _.
      Parameters:
      key - the type within the plugin's namespace
    • namespaceOf

      @NotNull public static @NotNull String namespaceOf(@NotNull @NotNull org.bukkit.plugin.Plugin plugin)
      The namespace of(Plugin, String) gives a plugin's types.
    • parse

      @NotNull public static @NotNull Optional<CosmeticTypeKey> parse(@Nullable @Nullable String text)
      Reads a key written as namespace:key, ignoring case. A key without a namespace, such as gliders, names one of Zentrix's own categories.
      Returns:
      empty when the text is not a key
    • isBuiltIn

      public boolean isBuiltIn()
      Whether this names one of Zentrix's own categories.
    • getCategory

      @NotNull public @NotNull Optional<CosmeticCategory> getCategory()
      The built-in category this names; empty for an addon's type.
    • asString

      @NotNull public @NotNull String asString()
      The key as namespace:key.
    • toString

      public 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.
    • namespace

      @NotNull public @NotNull String namespace()
      Returns the value of the namespace record component.
      Returns:
      the value of the namespace record component
    • key

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