Interface ZentrixRecipe


public interface ZentrixRecipe
Represents a custom recipe registered with Zentrix.

This interface provides read-only access to recipe information. To create new recipes, use RecipeBuilder.

IMPORTANT: Craft Limits are GLOBAL per World!

Craft limits restrict how many TOTAL times a recipe can be crafted in a world/game, not per player:

  • One-time: Only 1 player total can craft it per world
  • Craft limit (e.g., 9): Only 9 total crafts per world (any players)
  • Unlimited: Any number of players can craft unlimited times

Recipe Types

Example Usage


 RecipeService recipeService = api.getRecipeService();
 Optional<ZentrixRecipe> recipe = recipeService.getRecipe("my-recipe");

 recipe.ifPresent(r -> {
     System.out.println("Recipe: " + r.getId());
     System.out.println("Result: " + r.getResult().getType());
     System.out.println("Type: " + r.getType());

     if (r.isOneTime()) {
         System.out.println("This recipe can only be crafted once per player!");
     }
 });
 
Since:
1.0.1
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    Recipe type enumeration.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Gets the GLOBAL craft limit for this recipe.
    @NotNull Optional<String>
    Gets the creation timestamp of this recipe.
    @NotNull Optional<String>
    Gets the name of the player who created this recipe.
    @Nullable Object
    getCustomField(@NotNull String key)
    Gets a custom metadata field value.
    <T> T
    getCustomField(@NotNull String key, @NotNull Class<T> type)
    Gets a custom metadata field value with type casting.
    @NotNull Map<String,Object>
    Gets all custom metadata fields.
    @NotNull String
    Gets the unique identifier of this recipe.
    @NotNull List<org.bukkit.inventory.ItemStack>
    Gets the ingredients required for this recipe.
    @NotNull String[]
    Gets the crafting pattern for shaped recipes.
    @NotNull org.bukkit.inventory.ItemStack
    Gets the result item that this recipe produces.
    default int
    Gets the number of items produced by this recipe.
    Gets the type of this recipe.
    default boolean
    Checks if this recipe has a GLOBAL craft limit.
    boolean
    hasCustomField(@NotNull String key)
    Checks if this recipe has a custom metadata field.
    boolean
    Checks if this recipe is a one-time recipe.
    default boolean
    Checks if this is a shaped recipe.
    default boolean
    Checks if this is a shapeless recipe.
  • Method Details

    • getId

      @NotNull @NotNull String getId()
      Gets the unique identifier of this recipe.

      Recipe IDs are lowercase and contain only alphanumeric characters, hyphens, and underscores.

      Returns:
      The recipe ID (e.g., "diamond-sword-upgrade")
    • getResult

      @NotNull @NotNull org.bukkit.inventory.ItemStack getResult()
      Gets the result item that this recipe produces.

      The returned ItemStack is a clone and can be safely modified.

      Returns:
      A clone of the result ItemStack
    • getType

      @NotNull @NotNull ZentrixRecipe.RecipeType getType()
      Gets the type of this recipe.
      Returns:
      The recipe type (SHAPED or SHAPELESS)
    • isShaped

      default boolean isShaped()
      Checks if this is a shaped recipe.
      Returns:
      true if this is a shaped recipe
    • isShapeless

      default boolean isShapeless()
      Checks if this is a shapeless recipe.
      Returns:
      true if this is a shapeless recipe
    • getIngredients

      @NotNull @NotNull List<org.bukkit.inventory.ItemStack> getIngredients()
      Gets the ingredients required for this recipe.

      For shaped recipes, the list represents the 3x3 crafting grid in row-major order (indices 0-2 are top row, 3-5 middle, 6-8 bottom). Empty slots are represented as null or AIR items.

      For shapeless recipes, the list contains only the required ingredients without position information.

      The returned ItemStacks are clones and can be safely modified.

      Returns:
      List of ingredient ItemStacks
    • getPattern

      @NotNull @NotNull String[] getPattern()
      Gets the crafting pattern for shaped recipes.

      Returns a 3-element array where each string represents a row of the crafting grid. Characters in the pattern map to ingredients.

      For shapeless recipes, this returns an empty array.

      Returns:
      The pattern array, or empty array for shapeless recipes
    • isOneTime

      boolean isOneTime()
      Checks if this recipe is a one-time recipe.

      IMPORTANT: One-time means only 1 player TOTAL can craft this recipe per world/game, not once per player!

      Example: If Player A crafts a one-time recipe, Player B cannot craft it in the same world/game.

      Returns:
      true if this is a one-time recipe (1 total craft per world)
    • getCraftLimit

      int getCraftLimit()
      Gets the GLOBAL craft limit for this recipe.

      IMPORTANT: The craft limit is GLOBAL per world/game, not per player! This restricts how many TOTAL times the recipe can be crafted in a world by ANY players combined.

      Example: If craft limit is 9, only 9 total crafts are allowed in the world, regardless of which players craft it.

      Returns:
      The GLOBAL craft limit, or -1 if unlimited
    • hasCraftLimit

      default boolean hasCraftLimit()
      Checks if this recipe has a GLOBAL craft limit.

      Note: Craft limits are GLOBAL per world, not per player!

      Returns:
      true if this recipe has a GLOBAL craft limit (> 0)
    • getCreator

      @NotNull @NotNull Optional<String> getCreator()
      Gets the name of the player who created this recipe.
      Returns:
      The creator's name, or empty if unknown
    • getCreationTime

      @NotNull @NotNull Optional<String> getCreationTime()
      Gets the creation timestamp of this recipe.
      Returns:
      The creation time as ISO-8601 string, or empty if unknown
    • hasCustomField

      boolean hasCustomField(@NotNull @NotNull String key)
      Checks if this recipe has a custom metadata field.
      Parameters:
      key - The field key
      Returns:
      true if the field exists
    • getCustomField

      @Nullable @Nullable Object getCustomField(@NotNull @NotNull String key)
      Gets a custom metadata field value.

      Custom fields can store additional recipe metadata.

      Parameters:
      key - The field key
      Returns:
      The field value, or null if not found
    • getCustomField

      @Nullable <T> T getCustomField(@NotNull @NotNull String key, @NotNull @NotNull Class<T> type)
      Gets a custom metadata field value with type casting.
      Type Parameters:
      T - The expected type
      Parameters:
      key - The field key
      type - The expected type class
      Returns:
      The field value cast to the type, or null if not found or wrong type
    • getCustomFields

      @NotNull @NotNull Map<String,Object> getCustomFields()
      Gets all custom metadata fields.

      The returned map is a copy and modifications won't affect the recipe.

      Returns:
      Map of all custom fields
    • getResultAmount

      default int getResultAmount()
      Gets the number of items produced by this recipe.
      Returns:
      The result amount (usually matches result ItemStack amount)