Class Items

java.lang.Object
space.maxus.flare.item.Items

public final class Items extends Object
A utility class for manipulations with items inside Flare
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final org.bukkit.inventory.ItemStack
    Deprecated, for removal: This API element is subject to removal in a future version.
    Scheduled to be removed when local error handling is implemented (approx.
  • Method Summary

    Modifier and Type
    Method
    Description
    builder(org.bukkit.Material material)
    Constructs a new item stack builder for provided item type
    builder(org.bukkit.Material material, @Nullable org.bukkit.entity.Player player)
    Constructs a new item stack builder for provided item type with PlaceholderAPI placeholder support
    static org.bukkit.inventory.ItemStack
    Constructs an empty ItemStack of type Material.GRAY_STAINED_GLASS_PANE.
    static org.bukkit.inventory.ItemStack
    empty(org.bukkit.Material material)
    Constructs an ItemStack with empty name and lore of provided Material
    static org.bukkit.inventory.ItemStack
    Deprecated.
    Scheduled to be removed when local error handling is implemented (approx.
    static org.bukkit.inventory.ItemStack
    head(String skin)
    Constructs a new player head item with provided skin Base64 string.
    static org.bukkit.inventory.ItemStack
    head(String skin, Consumer<org.bukkit.inventory.meta.SkullMeta> configurator)
    Constructs a new player head item with provided skin Base64 string and additional meta.
    static <T extends org.bukkit.inventory.meta.ItemMeta>
    Consumer<T>
    Returns a consumer that will set the lore of item
    static <T extends org.bukkit.inventory.meta.ItemMeta>
    Consumer<T>
    loreMeta(String lore, @Nullable org.bukkit.entity.Player player)
    Returns a consumer that will set the lore of item
    static org.bukkit.inventory.ItemStack
    withLore(org.bukkit.Material material, @NotNull String lore)
    Constructs a new item stack with provided lore
    static org.bukkit.inventory.ItemStack
    withMeta(org.bukkit.Material material, @NotNull Consumer<org.bukkit.inventory.meta.ItemMeta> configurator)
    Constructs a new item with provided material and meta.
    static org.bukkit.inventory.ItemStack
    withName(org.bukkit.Material material, @NotNull String name)
    Constructs a new item stack with provided lore
    static org.bukkit.inventory.ItemStack
    withName(org.bukkit.Material material, @NotNull String name, @Nullable org.bukkit.entity.Player player)
    Constructs a new item stack with provided lore
    static <M extends org.bukkit.inventory.meta.ItemMeta>
    org.bukkit.inventory.ItemStack
    withTypedMeta(org.bukkit.Material material, @NotNull Consumer<M> configurator)
    Constructs a new item with provided material and meta of certain type.

    Methods inherited from class java.lang.Object

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

    • genericErrorItem

      @ScheduledForRemoval(inVersion="1.1.0") @Deprecated(since="0.9.0", forRemoval=true) public static final org.bukkit.inventory.ItemStack genericErrorItem
      Deprecated, for removal: This API element is subject to removal in a future version.
      Scheduled to be removed when local error handling is implemented (approx. 1.1.0)
      A generic error item returned when an error happens while building an item.
  • Method Details

    • loreMeta

      public static <T extends org.bukkit.inventory.meta.ItemMeta> Consumer<T> loreMeta(String lore)
      Returns a consumer that will set the lore of item
      Type Parameters:
      T - Type of item meta
      Parameters:
      lore - Lore to be transformed into components via FlareUtil.partitionString(String)
      Returns:
      A consumer that takes item meta and applies lore to it
    • loreMeta

      public static <T extends org.bukkit.inventory.meta.ItemMeta> Consumer<T> loreMeta(String lore, @Nullable @Nullable org.bukkit.entity.Player player)
      Returns a consumer that will set the lore of item
      Type Parameters:
      T - Type of item meta
      Parameters:
      lore - Lore to be transformed into components via FlareUtil.partitionString(String)
      player - Player used for PlaceholderAPI Placeholder resolution
      Returns:
      A consumer that takes item meta and applies lore to it
    • head

      public static org.bukkit.inventory.ItemStack head(String skin)
      Constructs a new player head item with provided skin Base64 string.
      Skin can be taken from Minecraft Heads, Crafatar or any other API.
      Parameters:
      skin - Base64 skin string to be applied to player
      Returns:
      Constructed ItemStack
    • head

      public static org.bukkit.inventory.ItemStack head(String skin, Consumer<org.bukkit.inventory.meta.SkullMeta> configurator)
      Constructs a new player head item with provided skin Base64 string and additional meta.
      Skin can be taken from Minecraft Heads, Crafatar or any other API.
      Parameters:
      skin - Base64 skin string to be applied to player
      configurator - Consumer that applies extra data to item meta
      Returns:
      Constructed ItemStack
    • withTypedMeta

      public static <M extends org.bukkit.inventory.meta.ItemMeta> org.bukkit.inventory.ItemStack withTypedMeta(org.bukkit.Material material, @NotNull @NotNull Consumer<M> configurator)
      Constructs a new item with provided material and meta of certain type.
      NOTE: will return genericErrorItem if meta is not of expected type.
      Type Parameters:
      M - Type of meta to be applied. Must match meta of provided material
      Parameters:
      material - Material of the item
      configurator - Consumer that takes ItemMeta of type Items and applies extra data to it
      Returns:
      A new ItemStack with provided material and meta.
    • withMeta

      public static org.bukkit.inventory.ItemStack withMeta(org.bukkit.Material material, @NotNull @NotNull Consumer<org.bukkit.inventory.meta.ItemMeta> configurator)
      Constructs a new item with provided material and meta.
      Parameters:
      material - Material of the item
      configurator - Consumer that takes ItemMeta and applies extra data to it
      Returns:
      A new ItemStack with provided material and meta.
    • withLore

      public static org.bukkit.inventory.ItemStack withLore(org.bukkit.Material material, @NotNull @NotNull String lore)
      Constructs a new item stack with provided lore
      Parameters:
      material - Material of the item
      lore - Lore to be applied to item via loreMeta(String)
      Returns:
      A new item stack with provided lore
    • withName

      public static org.bukkit.inventory.ItemStack withName(org.bukkit.Material material, @NotNull @NotNull String name)
      Constructs a new item stack with provided lore
      Parameters:
      material - Material of the item
      name - Name to be applied to item
      Returns:
      A new item stack with provided lore
    • withName

      public static org.bukkit.inventory.ItemStack withName(org.bukkit.Material material, @NotNull @NotNull String name, @Nullable @Nullable org.bukkit.entity.Player player)
      Constructs a new item stack with provided lore
      Parameters:
      material - Material of the item
      name - Name to be applied to item
      player - Player used for PlaceholderAPI placeholder resolution
      Returns:
      A new item stack with provided lore
    • builder

      public static ItemStackBuilder builder(org.bukkit.Material material)
      Constructs a new item stack builder for provided item type
      Parameters:
      material - Material of the item
      Returns:
      A new item stack builder
    • builder

      public static ItemStackBuilder builder(org.bukkit.Material material, @Nullable @Nullable org.bukkit.entity.Player player)
      Constructs a new item stack builder for provided item type with PlaceholderAPI placeholder support
      Parameters:
      material - Material of the item
      player - Player to be used for PlaceholderAPI placeholder resolution
      Returns:
      A new item stack builder
    • empty

      public static org.bukkit.inventory.ItemStack empty(org.bukkit.Material material)
      Constructs an ItemStack with empty name and lore of provided Material
      Parameters:
      material - Material of the ItemStack to be constructed
      Returns:
      Constructed ItemStack
    • empty

      public static org.bukkit.inventory.ItemStack empty()
      Constructs an empty ItemStack of type Material.GRAY_STAINED_GLASS_PANE. Can be useful for creating backgrounds
      Returns:
      Empty ItemStack of type Material.GRAY_STAINED_GLASS_PANE
    • getGenericErrorItem

      @Deprecated public static org.bukkit.inventory.ItemStack getGenericErrorItem()
      Deprecated.
      Scheduled to be removed when local error handling is implemented (approx. 1.1.0)
      A generic error item returned when an error happens while building an item.