Class RecipeSnapshot

java.lang.Object
io.github.bakedlibs.dough.recipes.RecipeSnapshot

public class RecipeSnapshot extends Object
This class represents a Snapshot of the Server's registered Recipes.
Author:
TheBusyBiscuit
  • Constructor Details

    • RecipeSnapshot

      public RecipeSnapshot(@Nonnull Plugin plugin)
      This will create a Snapshot of all Recipes on the plugin's Server.
      Parameters:
      plugin - The Plugin running on the Server that serves as the Snapshot's source.
  • Method Details

    • streamAllRecipes

      @Nonnull public Stream<Recipe> streamAllRecipes()
      This will stream all Recipes stored in this Snapshot.
      Returns:
      A Stream of all Recipes in this Snapshot
    • getRecipes

      @Nonnull public <T extends Recipe> Set<T> getRecipes(@Nonnull Class<T> recipeClass)
      This method will return a Set of Recipes of the given Type contained in this RecipeSnapshot.
      Type Parameters:
      T - The Type of recipeClass
      Parameters:
      recipeClass - A child-class of Recipe.
      Returns:
      A Set of Recipes of the given Type.
    • stream

      @Nonnull public <T extends Recipe> Stream<T> stream(@Nonnull Class<T> recipeClass)
      This method will return a Stream of Recipes of the given Type contained in this RecipeSnapshot.
      Type Parameters:
      T - The Type of recipeClass
      Parameters:
      recipeClass - A child-class of Recipe.
      Returns:
      A Stream of Recipes of the given Type.
    • getRecipeInput

      @Nonnull public <T extends Recipe> RecipeChoice[] getRecipeInput(@Nonnull MinecraftRecipe<? super T> recipeType, @Nonnull T recipe)
      This method will return an Array of RecipeChoice representing the given Recipe's input choices.
      Type Parameters:
      T - The Type of recipe
      Parameters:
      recipeType - The Type of the given Recipe
      recipe - The Recipe to get the inputs from
      Returns:
      The Inputs for the given Recipe
    • getRecipeInput

      @Nonnull public <T extends Recipe> RecipeChoice[] getRecipeInput(@Nonnull T recipe)
      This method will return an Array of RecipeChoice representing the given Recipe's input choices. This will perform a call to MinecraftRecipe.of(Recipe) to find the given Recipe's Recipe Type. It is advised to prefer the usage of getRecipeInput(MinecraftRecipe, Recipe).
      Type Parameters:
      T - The Type of recipe
      Parameters:
      recipe - The Recipe to get the inputs from
      Returns:
      The Inputs for the given Recipe
    • getRecipeOutput

      @Nonnull public <T extends Recipe> Optional<ItemStack> getRecipeOutput(@Nonnull MinecraftRecipe<T> recipeType, ItemStack... inputs)
      This method will return an Optional describing the output of a Recipe with the given type and given inputs. If no matching recipe was found, an empty Optional will be returned.
      Type Parameters:
      T - The Type of recipe
      Parameters:
      recipeType - The Recipe Type you are looking for
      inputs - The Inputs to the Recipe you are looking for
      Returns:
      An Optional describing the output of the Recipe matching your type and inputs
    • getRecipes

      @Nonnull public Set<Recipe> getRecipes(@Nonnull Predicate<Recipe> predicate)
      This method will return all Recipes matching the given Predicate.
      Parameters:
      predicate - The Predicate to filter recipes.
      Returns:
      A Set of Recipes matching your filter.
    • getRecipesFor

      @Nonnull public Set<Recipe> getRecipesFor(@Nonnull Material type)
      This method will return a Set of Recipes that result in an ItemStack with the given Material.
      Parameters:
      type - The Material of your Recipes' outputs.
      Returns:
      A Set of Recipes resulting in an ItemStack with the given Material
    • getRecipesFor

      @Nonnull public Set<Recipe> getRecipesFor(@Nonnull ItemStack item)
      This method will return a Set of Recipes that result in the given ItemStack.
      Parameters:
      item - The Result of the Recipes you are looking for
      Returns:
      A Set of Recipes resulting in the given ItemStack
    • getRecipesWith

      @Nonnull public Set<Recipe> getRecipesWith(@Nonnull ItemStack item)
      This method will return a Set of Recipes that take in the given ItemStack. Precisely: A Recipe will be included in this Set if one of the RecipeChoice inputs matches the given ItemStack
      Parameters:
      item - The ItemStack input for the Recipes you are looking for.
      Returns:
      A Set of Recipes that include the given ItemStack as an input.
    • getRecipe

      @Nullable public Recipe getRecipe(@Nonnull NamespacedKey key)
      This method will return a Recipe based on the provided NamespacedKey (if that Recipe is of type Keyed) The method works similar to Bukkit.getRecipe(NamespacedKey), though it is significantly faster since we operate on a cached HashMap and don't have to perform any data conversion.
      Parameters:
      key - The NamespacedKey
      Returns:
      The corresponding Recipe or null