Class MinecraftRecipeService
java.lang.Object
io.github.thebusybiscuit.slimefun4.core.services.MinecraftRecipeService
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
ConstructorsConstructorDescriptionMinecraftRecipeService
(org.bukkit.plugin.Plugin plugin) This constructs a newMinecraftRecipeService
for the givenPlugin
. -
Method Summary
Modifier and TypeMethodDescriptionOptional
<org.bukkit.inventory.ItemStack> getFurnaceOutput
(org.bukkit.inventory.ItemStack input) This method returns anOptional
describing the output of aFurnaceRecipe
with the givenItemStack
as an input.org.bukkit.inventory.Recipe
getRecipe
(org.bukkit.NamespacedKey key) This returns the correspondingKeyed
Recipe
for the givenNamespacedKey
.org.bukkit.inventory.Recipe[]
getRecipesFor
(org.bukkit.inventory.ItemStack item) This returns an array containing allRecipes
for crafting the givenItemStack
.org.bukkit.inventory.RecipeChoice[]
getRecipeShape
(org.bukkit.inventory.Recipe recipe) This returns the shape of a givenRecipe
.boolean
isSmeltable
(org.bukkit.inventory.ItemStack input) This returns whether a givenItemStack
can be smelted in aFurnaceRecipe
.void
refresh()
This method refreshes theRecipeSnapshot
that is used by theMinecraftRecipeService
.void
This method subscribes to the underlyingRecipeSnapshot
.
-
Constructor Details
-
MinecraftRecipeService
public MinecraftRecipeService(@Nonnull org.bukkit.plugin.Plugin plugin) This constructs a newMinecraftRecipeService
for the givenPlugin
. Slimefun already has aMinecraftRecipeService
so creating your own won't be of much use unless you wanna expand upon it. It is advised to use Slimefun's built-inMinecraftRecipeService
though.- Parameters:
plugin
- ThePlugin
that requests this Service
-
-
Method Details
-
refresh
public void refresh()This method refreshes theRecipeSnapshot
that is used by theMinecraftRecipeService
. -
subscribe
public void subscribe(@Nonnull Consumer<io.github.bakedlibs.dough.recipes.RecipeSnapshot> subscription) This method subscribes to the underlyingRecipeSnapshot
. When theServer
has finished loading and aCollection
of allRecipes
is created, the given callback will be run.- Parameters:
subscription
- A callback to run when theRecipeSnapshot
has been created.
-
getFurnaceOutput
@Nonnull public Optional<org.bukkit.inventory.ItemStack> getFurnaceOutput(@Nullable org.bukkit.inventory.ItemStack input) This method returns anOptional
describing the output of aFurnaceRecipe
with the givenItemStack
as an input.- Parameters:
input
- The inputItemStack
- Returns:
- An
Optional
describing the furnace output of the givenItemStack
-
isSmeltable
public boolean isSmeltable(@Nullable org.bukkit.inventory.ItemStack input) This returns whether a givenItemStack
can be smelted in aFurnaceRecipe
.- Parameters:
input
- TheItemStack
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 givenRecipe
. For any shapelessRecipe
the result will be equivalent toRecipeSnapshot.getRecipeInput(Recipe)
. For aShapedRecipe
this method will fix the order so it matches a 3x3 crafting grid.- Parameters:
recipe
- TheRecipe
to get the shape from- Returns:
- An Array of
RecipeChoice
representing the shape of thisRecipe
-
getRecipesFor
@Nonnull public org.bukkit.inventory.Recipe[] getRecipesFor(@Nullable org.bukkit.inventory.ItemStack item) This returns an array containing allRecipes
for crafting the givenItemStack
.- Parameters:
item
- TheItemStack
for which to get the recipes- Returns:
- An array of
Recipes
to craft the givenItemStack
-
getRecipe
@Nullable public org.bukkit.inventory.Recipe getRecipe(@Nonnull org.bukkit.NamespacedKey key) This returns the correspondingKeyed
Recipe
for the givenNamespacedKey
. If noRecipe
was found, null will be returned. This is a significantly faster method overBukkit.getRecipe(NamespacedKey)
since we operate on a cachedHashMap
- Parameters:
key
- TheNamespacedKey
- Returns:
- The corresponding
Recipe
or null
-