Interface ZentrixRecipe
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
ZentrixRecipe.RecipeType.SHAPED- Ingredients must be in specific positionsZentrixRecipe.RecipeType.SHAPELESS- Ingredients can be in any position
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 ClassesModifier and TypeInterfaceDescriptionstatic enumAvailable recipe types. -
Method Summary
Modifier and TypeMethodDescriptiondefault @NotNull OptionalIntGets the cooking time of a furnace, blast furnace, smoker or campfire recipe.intGets 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.Gets the game types this recipe is switched off in, lowercase.Gets the phases this recipe is switched off in, lowercase.default floatGets the experience a furnace, blast furnace or smoker recipe awards.@NotNull StringgetId()Gets the unique identifier of this recipe.default @NotNull List<RecipeIngredient> Gets every ingredient with every item it accepts.@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.default @NotNull RecipeStationGets the workstation this recipe is made at.@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.Only meaningful for crafting-table recipes. Every other workstation recipe reports
ZentrixRecipe.RecipeType.SHAPED, as it always has; usegetStation()to tell them apart.- Returns:
- The recipe type (SHAPED or SHAPELESS)
-
getStation
Gets the workstation this recipe is made at.- Returns:
- The station;
RecipeStation.OTHERfor a type Zentrix has no editor for - Since:
- 1.8.0
-
getCookingTime
Gets the cooking time of a furnace, blast furnace, smoker or campfire recipe.- Returns:
- The cooking time in ticks, or empty when the station does not cook
- Since:
- 1.8.0
-
getExperience
default float getExperience()Gets the experience a furnace, blast furnace or smoker recipe awards.- Returns:
- The experience, or 0 when the station awards none
- Since:
- 1.8.0
-
getIngredientChoices
Gets every ingredient with every item it accepts.getIngredients()shows one representative item per ingredient and loses the other accepted items; this keeps them, along with how each ingredient compares items. Shaped ingredients come in pattern-key order, others in recipe order.- Returns:
- The ingredients (never null)
- Since:
- 1.8.0
-
getDisabledPhases
Gets the phases this recipe is switched off in, lowercase. While a match is in one of them the recipe behaves as if it did not exist.- Returns:
- The phase names (never null)
- Since:
- 1.8.0
-
getDisabledGameTypes
Gets the game types this recipe is switched off in, lowercase.- Returns:
- The game type names (never null)
- Since:
- 1.8.0
-
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.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
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)
-