Interface ItemProvider


public interface ItemProvider
A source of custom items addressed as <namespace>:<id>, next to Zentrix's built-in custom:, itemsadder: and nexo: prefixes.

Once registered through ItemService.registerItemProvider(org.bukkit.plugin.Plugin, dev.itsharshxd.zentrix.api.item.ItemProvider), identifiers in the provider's namespace work wherever Zentrix resolves or matches item identifiers through its item manager: ItemService.resolveItem(java.lang.String), ItemService.matchesItem(org.bukkit.inventory.ItemStack, java.lang.String), and configuration that refers to items by identifier when it is used, such as class bonus items. The material of entries in content/items.yml is resolved when that file is read - at Zentrix's startup, before dependent addons enable - so such entries resolve from the next /zentrix reload after the provider registered. Loot pools store their items themselves and are not affected.

Calls come from the main thread and must be quick; a provider that throws is treated as not knowing the item.

Since:
1.8.0
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable org.bukkit.inventory.ItemStack
    createItem(@NotNull String id)
    Creates the item with this ID.
    default @NotNull Set<String>
    Every item ID the provider knows, without the namespace, for suggestions and pickers.
    @NotNull String
    The namespace identifiers of this provider start with, without the colon: lowercase a-z, 0-9, _ and -.
    @Nullable String
    identify(@NotNull org.bukkit.inventory.ItemStack item)
    The ID of an item this provider made, so Zentrix can match it against an identifier.
    default boolean
    Whether the provider can create items now, for instance once its own content has loaded.
  • Method Details

    • getNamespace

      @NotNull @NotNull String getNamespace()
      The namespace identifiers of this provider start with, without the colon: lowercase a-z, 0-9, _ and -. custom, itemsadder, nexo, minecraft and zentrix are reserved.
    • isAvailable

      default boolean isAvailable()
      Whether the provider can create items now, for instance once its own content has loaded.
    • createItem

      @Nullable @Nullable org.bukkit.inventory.ItemStack createItem(@NotNull @NotNull String id)
      Creates the item with this ID.
      Parameters:
      id - the part after <namespace>:
      Returns:
      a new stack, or null when no such item exists
    • identify

      @Nullable @Nullable String identify(@NotNull @NotNull org.bukkit.inventory.ItemStack item)
      The ID of an item this provider made, so Zentrix can match it against an identifier.
      Returns:
      the part after <namespace>:, or null when the item is not one of this provider's
    • getItemIds

      @NotNull default @NotNull Set<String> getItemIds()
      Every item ID the provider knows, without the namespace, for suggestions and pickers.