Class ItemNameGenerator

java.lang.Object
net.okocraft.box.api.util.ItemNameGenerator

@Experimental public final class ItemNameGenerator extends Object
A utility class for generating item names.
  • Method Summary

    Modifier and Type
    Method
    Description
    static @NotNull String
    itemStack(@NotNull net.kyori.adventure.key.Keyed key, byte @NotNull [] bytes)
    Creates the name from the ItemStack.
    static @NotNull String
    itemStack(@NotNull org.bukkit.inventory.ItemStack itemStack)
    Creates the name from the ItemStack.
    static @NotNull String
    key(@NotNull net.kyori.adventure.key.Key key)
    Creates the name from the Key.
    static @NotNull String
    key(@NotNull net.kyori.adventure.key.Keyed key)
    Creates the name from the Keyed.
    static @NotNull String
    keys(@NotNull net.kyori.adventure.key.Keyed key1, @NotNull net.kyori.adventure.key.Keyed key2)
    Creates the name from the Keyeds.
    static @NotNull String
    keys(@NotNull net.kyori.adventure.key.Keyed key1, @NotNull net.kyori.adventure.key.Keyed key2, @NotNull net.kyori.adventure.key.Keyed @NotNull ... keys)
    Creates the name from the Keyeds.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • key

      @NotNull public static @NotNull String key(@NotNull @NotNull net.kyori.adventure.key.Key key)
      Creates the name from the Key.

      If Key.namespace() is Key.MINECRAFT_NAMESPACE, this method returns only uppercase Key.value(). Otherwise, returns the name in the format NAMESPACE_VALUE.

      Parameters:
      key - the Key to create the name
      Returns:
      the created name
    • key

      @NotNull public static @NotNull String key(@NotNull @NotNull net.kyori.adventure.key.Keyed key)
      Creates the name from the Keyed.
      Parameters:
      key - the Keyed to create the name
      Returns:
      the created name
      See Also:
    • keys

      @NotNull public static @NotNull String keys(@NotNull @NotNull net.kyori.adventure.key.Keyed key1, @NotNull @NotNull net.kyori.adventure.key.Keyed key2)
      Creates the name from the Keyeds.

      This method returns the name of two key(Keyed) results joined by _.

      Parameters:
      key1 - the first Keyed to create the name
      key2 - the second Keyed to create the name
      Returns:
      the created name
      See Also:
    • keys

      @NotNull public static @NotNull String keys(@NotNull @NotNull net.kyori.adventure.key.Keyed key1, @NotNull @NotNull net.kyori.adventure.key.Keyed key2, @NotNull @NotNull net.kyori.adventure.key.Keyed @NotNull ... keys)
      Creates the name from the Keyeds.

      This method returns the name of key(Keyed) results joined by _.

      Parameters:
      key1 - the first Keyed to create the name
      key2 - the second Keyed to create the name
      keys - the other Keyeds to create the name
      Returns:
      the created name
      See Also:
    • itemStack

      @NotNull public static @NotNull String itemStack(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
      Creates the name from the ItemStack.

      This method passes ItemStack.getType() and ItemStack.serializeAsBytes() to itemStack(Keyed, byte[]).

      Parameters:
      itemStack - the ItemStack to create the name
      Returns:
      the created name
      See Also:
    • itemStack

      @NotNull public static @NotNull String itemStack(@NotNull @NotNull net.kyori.adventure.key.Keyed key, byte @NotNull [] bytes)
      Creates the name from the ItemStack.

      This method returns the name in the format key_sha1.

      Parameters:
      key - the Keyed to create the name
      bytes - the bytes to create the hash value by SHA-1
      Returns:
      the created name