Class CraftRecipe
java.lang.Object
valorless.valorlessutils.crafting.CraftRecipe
- All Implemented Interfaces:
org.bukkit.event.Listener
Represents a custom crafting recipe in Minecraft.
Supports both shaped and shapeless recipes using the base Minecraft crafting system. Recipes can optionally require a permission to craft.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Enum representing the type of crafting recipe. -
Constructor Summary
ConstructorsConstructorDescriptionCraftRecipe
(org.bukkit.plugin.java.JavaPlugin plugin, String recipe, CraftRecipe.RecipeType type, List<Ingredient> ingredients, org.bukkit.inventory.ItemStack result, List<String>... shape) Constructs a new CraftRecipe. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add()
Adds this recipe to the server.Gets the ingredients of the recipe.org.bukkit.permissions.Permission
Gets the permission required to craft this recipe.org.bukkit.inventory.ItemStack
Gets the result of the recipe.GetShape()
Gets the shape of the recipe.GetType()
Gets the recipe type.void
onPrepareItemCraft
(org.bukkit.event.inventory.PrepareItemCraftEvent event) Event handler for when a player prepares an item for crafting.void
Remove()
Removes this recipe from the server.void
SetIngredients
(List<Ingredient> ingredients) Sets the ingredients of the recipe.void
SetPermission
(String permission) Sets the permission required to craft this recipe by string.void
SetPermission
(org.bukkit.permissions.Permission permission) Sets the permission required to craft this recipe directly.void
SetResult
(org.bukkit.inventory.ItemStack result) Sets the result of the recipe.void
Sets the shape of a shaped recipe.void
Sets the recipe type (shaped or shapeless).toString()
Returns a string representation of this CraftRecipe.
-
Constructor Details
-
CraftRecipe
@SafeVarargs public CraftRecipe(org.bukkit.plugin.java.JavaPlugin plugin, String recipe, CraftRecipe.RecipeType type, List<Ingredient> ingredients, org.bukkit.inventory.ItemStack result, List<String>... shape) Constructs a new CraftRecipe.- Parameters:
plugin
- The plugin used for the NamespacedKey.recipe
- The unique recipe ID.type
- The type of the recipe (shaped or shapeless).ingredients
- The ingredients required for crafting.result
- The resulting item.shape
- Optional shape for shaped recipes.
-
-
Method Details
-
SetShape
Sets the shape of a shaped recipe. -
GetShape
Gets the shape of the recipe. -
SetIngredients
Sets the ingredients of the recipe. -
GetIngredients
Gets the ingredients of the recipe. -
SetType
Sets the recipe type (shaped or shapeless). -
GetType
Gets the recipe type. -
SetPermission
Sets the permission required to craft this recipe by string.If null, no permission is required.
-
SetPermission
public void SetPermission(@Nullable org.bukkit.permissions.Permission permission) Sets the permission required to craft this recipe directly. -
GetPermission
public org.bukkit.permissions.Permission GetPermission()Gets the permission required to craft this recipe. -
SetResult
public void SetResult(org.bukkit.inventory.ItemStack result) Sets the result of the recipe. -
GetResult
public org.bukkit.inventory.ItemStack GetResult()Gets the result of the recipe. -
Remove
public void Remove()Removes this recipe from the server. -
Add
public void Add()Adds this recipe to the server. -
onPrepareItemCraft
public void onPrepareItemCraft(org.bukkit.event.inventory.PrepareItemCraftEvent event) Event handler for when a player prepares an item for crafting.Ensures that only players with the required permission can craft the recipe.
- Parameters:
event
- The PrepareItemCraftEvent.
-
toString
Returns a string representation of this CraftRecipe.
-