Class CraftRecipe

java.lang.Object
valorless.valorlessutils.crafting.CraftRecipe
All Implemented Interfaces:
org.bukkit.event.Listener

public class CraftRecipe extends Object implements 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.

  • 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

      public void SetShape(List<String> shape)
      Sets the shape of a shaped recipe.
    • GetShape

      public List<String> GetShape()
      Gets the shape of the recipe.
    • SetIngredients

      public void SetIngredients(List<Ingredient> ingredients)
      Sets the ingredients of the recipe.
    • GetIngredients

      public List<Ingredient> GetIngredients()
      Gets the ingredients of the recipe.
    • SetType

      public void SetType(CraftRecipe.RecipeType type)
      Sets the recipe type (shaped or shapeless).
    • GetType

      public CraftRecipe.RecipeType GetType()
      Gets the recipe type.
    • SetPermission

      public void SetPermission(@Nullable String permission)
      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

      public String toString()
      Returns a string representation of this CraftRecipe.
      Overrides:
      toString in class Object