Class MinecraftRecipeService

java.lang.Object
io.github.thebusybiscuit.slimefun4.core.services.MinecraftRecipeService

public class MinecraftRecipeService extends Object
This Service is responsible for accessing a RecipeSnapshot. This snapshot contains a compiled list of all recipes that could be found on the Server at the time the Service was loaded. This Service is primarily used by the SurvivalSlimefunGuide.
Author:
TheBusyBiscuit
  • Constructor Summary

    Constructors
    Constructor
    Description
    MinecraftRecipeService(org.bukkit.plugin.Plugin plugin)
    This constructs a new MinecraftRecipeService for the given Plugin.
  • Method Summary

    Modifier and Type
    Method
    Description
    Optional<org.bukkit.inventory.ItemStack>
    getFurnaceOutput(org.bukkit.inventory.ItemStack input)
    This method returns an Optional describing the output of a FurnaceRecipe with the given ItemStack as an input.
    org.bukkit.inventory.Recipe
    getRecipe(org.bukkit.NamespacedKey key)
    This returns the corresponding Keyed Recipe for the given NamespacedKey.
    org.bukkit.inventory.Recipe[]
    getRecipesFor(org.bukkit.inventory.ItemStack item)
    This returns an array containing all Recipes for crafting the given ItemStack.
    org.bukkit.inventory.RecipeChoice[]
    getRecipeShape(org.bukkit.inventory.Recipe recipe)
    This returns the shape of a given Recipe.
    boolean
    isSmeltable(org.bukkit.inventory.ItemStack input)
    This returns whether a given ItemStack can be smelted in a FurnaceRecipe.
    void
    This method refreshes the RecipeSnapshot that is used by the MinecraftRecipeService.
    void
    subscribe(Consumer<io.github.bakedlibs.dough.recipes.RecipeSnapshot> subscription)
    This method subscribes to the underlying RecipeSnapshot.

    Methods inherited from class java.lang.Object

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

    • MinecraftRecipeService

      public MinecraftRecipeService(@Nonnull org.bukkit.plugin.Plugin plugin)
      This constructs a new MinecraftRecipeService for the given Plugin. Slimefun already has a MinecraftRecipeService so creating your own won't be of much use unless you wanna expand upon it. It is advised to use Slimefun's built-in MinecraftRecipeService though.
      Parameters:
      plugin - The Plugin that requests this Service
  • Method Details

    • refresh

      public void refresh()
      This method refreshes the RecipeSnapshot that is used by the MinecraftRecipeService.
    • subscribe

      public void subscribe(@Nonnull Consumer<io.github.bakedlibs.dough.recipes.RecipeSnapshot> subscription)
      This method subscribes to the underlying RecipeSnapshot. When the Server has finished loading and a Collection of all Recipes is created, the given callback will be run.
      Parameters:
      subscription - A callback to run when the RecipeSnapshot has been created.
    • getFurnaceOutput

      @Nonnull public Optional<org.bukkit.inventory.ItemStack> getFurnaceOutput(@Nullable org.bukkit.inventory.ItemStack input)
      This method returns an Optional describing the output of a FurnaceRecipe with the given ItemStack as an input.
      Parameters:
      input - The input ItemStack
      Returns:
      An Optional describing the furnace output of the given ItemStack
    • isSmeltable

      public boolean isSmeltable(@Nullable org.bukkit.inventory.ItemStack input)
      This returns whether a given ItemStack can be smelted in a FurnaceRecipe.
      Parameters:
      input - The ItemStack to test
      Returns:
      Whether this item can be smelted
    • getRecipeShape

      @Nonnull public org.bukkit.inventory.RecipeChoice[] getRecipeShape(@Nonnull org.bukkit.inventory.Recipe recipe)
      This returns the shape of a given Recipe. For any shapeless Recipe the result will be equivalent to RecipeSnapshot.getRecipeInput(Recipe). For a ShapedRecipe this method will fix the order so it matches a 3x3 crafting grid.
      Parameters:
      recipe - The Recipe to get the shape from
      Returns:
      An Array of RecipeChoice representing the shape of this Recipe
    • getRecipesFor

      @Nonnull public org.bukkit.inventory.Recipe[] getRecipesFor(@Nullable org.bukkit.inventory.ItemStack item)
      This returns an array containing all Recipes for crafting the given ItemStack.
      Parameters:
      item - The ItemStack for which to get the recipes
      Returns:
      An array of Recipes to craft the given ItemStack
    • getRecipe

      @Nullable public org.bukkit.inventory.Recipe getRecipe(@Nonnull org.bukkit.NamespacedKey key)
      This returns the corresponding Keyed Recipe for the given NamespacedKey. If no Recipe was found, null will be returned. This is a significantly faster method over Bukkit.getRecipe(NamespacedKey) since we operate on a cached HashMap
      Parameters:
      key - The NamespacedKey
      Returns:
      The corresponding Recipe or null