Interface ItemRegistry


public interface ItemRegistry
Where items are declared: the vanilla ones, and the ones plugins invent.
Since:
0.1.0
  • Method Details

    • register

      void register(ItemDefinition definition, Plugin owner)
      Declares an item of its own.
      Parameters:
      definition - the item to declare
      owner - the plugin declaring it
      Throws:
      IllegalArgumentException - if ItemDefinition.networkType() is not a known item, or if the key shadows a vanilla item
      Since:
      0.1.0
    • unregister

      boolean unregister(Key itemType)
      Drops a definition declared through register(ItemDefinition, Plugin).
      Parameters:
      itemType - the key to drop
      Returns:
      true if a definition was registered under that key
      Since:
      0.1.0
    • unregisterAll

      void unregisterAll(Plugin owner)
      Drops every definition a plugin declared.
      Parameters:
      owner - the plugin to clean up after
      Since:
      0.1.0
    • definition

      Optional<ItemDefinition> definition(Key itemType)
      Parameters:
      itemType - the key to look up
      Returns:
      the definition registered under that key, empty for a vanilla item
      Since:
      0.1.0
    • definitions

      Collection<ItemDefinition> definitions()
      Returns:
      every definition registered by a plugin
      Since:
      0.1.0
    • types

      Set<Key> types()
      Returns:
      every key that can be created, vanilla items included
      Since:
      0.1.0
    • isItem

      boolean isItem(Key itemType)
      Parameters:
      itemType - the key to test
      Returns:
      true when a stack can be created under that key
      Since:
      0.1.0
    • isCustom

      boolean isCustom(Key itemType)
      Parameters:
      itemType - the key to test
      Returns:
      true when a plugin declared this key
      Since:
      0.1.0
    • networkType

      Key networkType(Key itemType)
      Resolves the vanilla item the client is sent for a key.
      Parameters:
      itemType - the key to resolve
      Returns:
      the declared ItemDefinition.networkType(), or the key itself when vanilla
      Since:
      0.1.0
    • create

      default ItemStack create(Key itemType)
      Creates a stack of one.
      Parameters:
      itemType - the item to create
      Returns:
      the stack, ItemStack.EMPTY when the key is unknown
      Since:
      0.1.0
    • create

      ItemStack create(Key itemType, int count)
      Creates a stack, pre-filled with the definition's components for a declared item.
      Parameters:
      itemType - the item to create
      count - how many
      Returns:
      the stack, ItemStack.EMPTY when the key is unknown
      Since:
      0.1.0