⚒️Crafting Recipes
Create custom crafting recipes with ease
Overview
The Crafting class provides a utility for creating custom crafting recipes in Bukkit.
Constructors
Crafting(JavaPlugin plugin, ItemStack result, String key)
Crafting(JavaPlugin plugin, ItemStack result, String key)public Crafting(JavaPlugin plugin, ItemStack result, String key)Creates a new instance of the Crafting class with the specified result item and recipe key.
Parameters
plugin: The JavaPlugin instance representing the plugin that owns this recipe.result: The ItemStack representing the result of the crafting recipe.key: The key used to identify this recipe.
Methods
setShape
setShapepublic Crafting setShape(String... shape)Sets the shape of the crafting recipe.
Parameters
shape: An array of strings representing the crafting grid.
setIngredient
setIngredientSets an ingredient for the crafting recipe using a Material.
Parameters
key: The character representing the ingredient's position in the crafting grid.material: The Material of the ingredient.amount: The amount of the ingredient required.
Sets an ingredient for the crafting recipe using an ItemStack.
Parameters
key: The character representing the ingredient's position in the crafting grid.itemStack: The ItemStack representing the ingredient.amount: The amount of the ingredient required.
build
buildBuilds and returns the ShapedRecipe instance representing the crafting recipe.
Usage
Create a new instance of the
Craftingclass with the desired result item and recipe key.Set the shape of the crafting recipe using the
setShapemethod.Add ingredients to the recipe using the
setIngredientmethod.Build the recipe using the
buildmethod.Register the recipe with Bukkit using
Bukkit.addRecipe.
Example
In this example, we create a custom crafting recipe for a diamond sword (result) using various materials and items.
Last updated