Interface RecipeRegistry


public interface RecipeRegistry
Where recipes are declared: the vanilla ones the server loads at startup, and the ones plugins add.

When a grid matches several recipes, the ones registered by plugins win over the vanilla ones, in the order they were registered. To replace a vanilla recipe outright, unregister it first.

Implementations are thread-safe.

Since:
0.1.0
  • Method Details

    • register

      void register(Recipe recipe, Object owner)
      Declares a recipe.
      Parameters:
      recipe - the recipe
      owner - the plugin declaring it, so that it can be dropped with the others when the plugin is disabled
      Throws:
      IllegalArgumentException - if a recipe is already registered under Recipe.key()
      Since:
      0.1.0
    • unregister

      boolean unregister(Key key)
      Drops a recipe, a vanilla one included.
      Parameters:
      key - the identifier of the recipe
      Returns:
      true if a recipe was registered under that key
      Since:
      0.1.0
    • unregisterAll

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

      Optional<Recipe> recipe(Key key)
      Parameters:
      key - the identifier of the recipe
      Returns:
      the recipe, empty when none is registered under that key
      Since:
      0.1.0
    • recipes

      Collection<Recipe> recipes()
      Returns:
      every registered recipe, plugin ones first, in matching order
      Since:
      0.1.0
    • isVanilla

      boolean isVanilla(Key key)
      Parameters:
      key - the identifier of the recipe
      Returns:
      true when that recipe comes from the vanilla data rather than a plugin
      Since:
      0.1.0
    • matchCrafting

      Optional<CraftingMatch> matchCrafting(CraftingInput input)
      Finds the recipe a crafting grid makes, the way a crafting table does.
      Parameters:
      input - the grid
      Returns:
      the first matching recipe, with what it gives and takes; empty when none matches
      Since:
      0.1.0
    • tags

      Returns:
      the item tags the server resolves tag ingredients with
      Since:
      0.1.0