Interface ZentrixRecipe
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
ZentrixRecipe.RecipeType.SHAPED- Ingredients must be in specific positionsZentrixRecipe.RecipeType.SHAPELESS- Ingredients can be in any position
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 ClassesModifier and TypeInterfaceDescriptionstatic enumRecipe type enumeration. -
Method Summary
Modifier and TypeMethodDescriptionintGets the GLOBAL craft limit for this recipe.Gets the creation timestamp of this recipe.Gets the name of the player who created this recipe.@Nullable ObjectgetCustomField(@NotNull String key) Gets a custom metadata field value.<T> TgetCustomField(@NotNull String key, @NotNull Class<T> type) Gets a custom metadata field value with type casting.Gets all custom metadata fields.@NotNull StringgetId()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.ItemStackGets the result item that this recipe produces.default intGets the number of items produced by this recipe.@NotNull ZentrixRecipe.RecipeTypegetType()Gets the type of this recipe.default booleanChecks if this recipe has a GLOBAL craft limit.booleanhasCustomField(@NotNull String key) Checks if this recipe has a custom metadata field.booleanChecks if this recipe is a one-time recipe.default booleanisShaped()Checks if this is a shaped recipe.default booleanChecks if this is a shapeless recipe.
-
Method Details
-
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
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
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
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
Gets the name of the player who created this recipe.- Returns:
- The creator's name, or empty if unknown
-
getCreationTime
Gets the creation timestamp of this recipe.- Returns:
- The creation time as ISO-8601 string, or empty if unknown
-
hasCustomField
Checks if this recipe has a custom metadata field.- Parameters:
key- The field key- Returns:
- true if the field exists
-
getCustomField
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
Gets a custom metadata field value with type casting.- Type Parameters:
T- The expected type- Parameters:
key- The field keytype- The expected type class- Returns:
- The field value cast to the type, or null if not found or wrong type
-
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)
-