Interface ZentrixRecipe


public interface ZentrixRecipe
Custom recipe registered with Zentrix.

Use RecipeBuilder to create recipes; this interface exposes their configuration.

Craft limits

Craft limits restrict the total number of crafts in a world or game, not per player:

  • One-time: One player total can craft it per world
  • Craft limit (e.g., 9): Nine total crafts per world
  • Unlimited: Players can craft it without a limit

Recipe types

Example


 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 
    Available recipe types.
  • 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.

      Note: One-time means one player total can craft this recipe per world or 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.

      Note: The craft limit is global per world or game, not per player. It restricts the total number of crafts by all players in that world.

      Example: A craft limit of 9 allows nine total crafts 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 apply globally 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)