Class RecipeUtil.Recipe
java.lang.Object
me.mehboss.utils.RecipeUtil.Recipe
- Direct Known Subclasses:
BrewingRecipeData,CookingRecipeData,CraftingRecipeData,WorkstationRecipeData
- Enclosing class:
RecipeUtil
Represents a fully defined custom recipe used by the CustomRecipes API.
A Recipe stores its output item, ingredient layout, behavior flags, permissions, cooldowns, optional commands, and metadata such as whether the recipe is shaped, shapeless, furnace-based, etc.
Only validated recipes should be added through RecipeUtil.createRecipe(me.mehboss.utils.RecipeUtil.Recipe).
Key features:
- result – the final ItemStack produced by crafting.
- ingredients – a list of ingredient entries, optionally exact.
- commands – commands executed when the recipe is crafted.
- name/key – human-readable name and NamespacedKey identifier.
- disabledWorlds – worlds where this recipe cannot be used.
- flags – behavior options such as exactChoice, ignoreData, ignoreModelData, ignoreNames, discoverable, grantItem, etc.
- shape rows – row1, row2, row3 for shaped crafting layouts.
- cooldown – optional per-player cooldown before recrafting.
This class serves as a simple data container. Logic is handled in RecipeUtil during registration and validation.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDisabledWorld(String world) Adds a world to the noCraft listvoidaddIngredient(RecipeUtil.Ingredient ingredient) Adds an Ingredient object to the recipe, required Requires 9 ingredients for crafting, 1 otherwiseArrayList<org.bukkit.Material> Compiles all ingredient materials of a recipeGetter for setBookCategoryGets the commands to perform upon crafting a recipelongGetter for the cooldownGetter for the custom ID outputGetter for worlds the recipe can not be crafted inbooleanGetter for ignoreDatabooleanGetter for ignoreModelDatabooleanGetter for ignoreNamesGetter for the recipe ingredientsintGetter for the amount of ingredients the recipe hasgetKey()Getter for the NamedspaceKeygetName()Getter for the recipe namegetPerm()Getter for the permission needed to craft the recipe, can be nullorg.bukkit.inventory.ItemStackGetter for the recipe resultgetRow(int row) Getter for the shaped recipe rowsgetSlot(int slot) Getter for an ingredient slotgetType()Getter for the RecipeTypebooleanGets whether the recipe is an item or a commandbooleanGetter for if the recipe has a cooldown setbooleanhasKey()Getter for if the recipe has a NamedspaceKeybooleanhasPerm()booleanisActive()Getter for setActive.booleanGetter for whether or not a recipe result is of a custom itembooleanGetter for checking if the recipe is tagged with the keybooleanGetter for setDiscoverablebooleanGetter for setExactChoicebooleanGets whether the recipe output should be granted after a command is performedbooleanGetter for setPlaceablevoidEnables or disables a recipevoidsetBookCategory(String category) Sets the category the recipe will be shown within the vanilla recipe book.voidsetCommands(List<String> commands) Sets the commands to perform upon crafting a recipevoidsetCooldown(long cooldown) Setter for the recipe cooldownvoidsetCustomItem(String customItem) Sets an ID for custom item resultsvoidsetDiscoverable(Boolean discoverable) Sets whether or not a recipe is going to be discovered automaticallyvoidsetExactChoice(Boolean exactChoice) Sets whether or not a recipe is going to be using exactChoice.voidsetGrantItem(Boolean grantItem) Sets whether the recipe output should be granted after a command is performedvoidsetIgnoreData(boolean ignoreData) Setter for if the recipe ignores MetaDatavoidsetIgnoreModelData(boolean ignoreModelData) Setter for if the recipe ignores CustomModelDatavoidsetIgnoreNames(boolean ignoreNames) Setter for if the recipe ignores namesvoidSetter for the NamedspaceKey, requiredvoidSetter for the permission needed to craft the recipevoidsetPlaceable(Boolean placeable) Sets whether or not a recipe is allowed to be placed.voidsetResult(org.bukkit.inventory.ItemStack result) Setter for the recipe result, requiredvoidSetter for the shaped recipe rows, requiredvoidsetTagged(boolean tagged) Setter for whether the result is tagged with the keyvoidSetter for the RecipeType, not required and defaults to SHAPED
-
Constructor Details
-
Recipe
Parameterized constructor. Initializes a Recipe object with specified name- Parameters:
name- the name of the recipe
-
-
Method Details
-
getBookCategory
Getter for setBookCategory- Returns:
- the Category enum the recipe belongs to in the recipe book.
-
setBookCategory
Sets the category the recipe will be shown within the vanilla recipe book.- Parameters:
category- CraftingBookCategory or CookingBookCategory, defaults to MISC
-
isDiscoverable
public boolean isDiscoverable()Getter for setDiscoverable- Returns:
- true if the recipe is discoverable, false otherwise.
-
setDiscoverable
Sets whether or not a recipe is going to be discovered automatically- Parameters:
discoverable- true or false boolean
-
isCustomItem
public boolean isCustomItem()Getter for whether or not a recipe result is of a custom item- Returns:
- true if the recipe output is custom, false otherwise.
-
setCustomItem
Sets an ID for custom item results- Parameters:
customItem- the ID of the custom item
-
getCustomItemID
-
isExactChoice
public boolean isExactChoice()Getter for setExactChoice- Returns:
- true if the recipe is exactChoice, false otherwise.
-
setExactChoice
Sets whether or not a recipe is going to be using exactChoice.- Parameters:
exactChoice- true or false boolean
-
isPlaceable
public boolean isPlaceable()Getter for setPlaceable- Returns:
- true if the recipe can be placed down, false otherwise.
-
setPlaceable
Sets whether or not a recipe is allowed to be placed.- Parameters:
placeable- true or false boolean
-
isActive
public boolean isActive()Getter for setActive.- Returns:
- true if the recipe is enabled, false otherwise.
-
setActive
Enables or disables a recipe- Parameters:
status- true or false boolean
-
getName
-
setRow
Setter for the shaped recipe rows, required- Parameters:
row- the recipe rowshape- the shape for the row (example: XDX)- Throws:
ArrayIndexOutOfBoundsException- if the integer specified is not rows 1-3
-
getRow
Getter for the shaped recipe rows- Parameters:
row- the recipe row- Throws:
ArrayIndexOutOfBoundsException- if the integer specified is not rows 1-3
-
setType
Setter for the RecipeType, not required and defaults to SHAPED- Parameters:
SHAPELESS- the recipe type will be shapelessSHAPED- the recipe type will be shapedFURNACE- the recipe type will be a furnace recipeSTONECUTTER- the recipe type will be a stonecutter recipe
-
getType
Getter for the RecipeType -
setTagged
public void setTagged(boolean tagged) Setter for whether the result is tagged with the key- Parameters:
tagged- tags if true, otherwise does not tag- Throws:
InvalidRecipeException- if the recipe result is nullInvalidRecipeException- if there is no key found
-
isCustomTagged
public boolean isCustomTagged()Getter for checking if the recipe is tagged with the key -
hasKey
public boolean hasKey()Getter for if the recipe has a NamedspaceKey -
setKey
Setter for the NamedspaceKey, required- Parameters:
key- the NamedspaceKey
-
getKey
Getter for the NamedspaceKey -
hasCooldown
public boolean hasCooldown()Getter for if the recipe has a cooldown set -
setCooldown
public void setCooldown(long cooldown) Setter for the recipe cooldown- Parameters:
cooldown- the cooldown in seconds
-
getCooldown
public long getCooldown()Getter for the cooldown -
setIgnoreData
public void setIgnoreData(boolean ignoreData) Setter for if the recipe ignores MetaData- Parameters:
ignoreData- true to ignore, otherwise false
-
getIgnoreData
public boolean getIgnoreData()Getter for ignoreData -
setIgnoreNames
public void setIgnoreNames(boolean ignoreNames) Setter for if the recipe ignores names- Parameters:
ignoreNames- true to ignore, otherwise false
-
getIgnoreNames
public boolean getIgnoreNames()Getter for ignoreNames -
setIgnoreModelData
public void setIgnoreModelData(boolean ignoreModelData) Setter for if the recipe ignores CustomModelData- Parameters:
ignoreModelData- true to ignore, otherwise false
-
getIgnoreModelData
public boolean getIgnoreModelData()Getter for ignoreModelData -
setResult
public void setResult(org.bukkit.inventory.ItemStack result) Setter for the recipe result, required- Parameters:
result- the ItemStack for the recipe result
-
getResult
public org.bukkit.inventory.ItemStack getResult()Getter for the recipe result -
addIngredient
Adds an Ingredient object to the recipe, required Requires 9 ingredients for crafting, 1 otherwise- Parameters:
ingredient- a finalized Ingredient for the recipe
-
getAllIngredientTypes
Compiles all ingredient materials of a recipe -
getIngredients
Getter for the recipe ingredients -
getIngredientSize
public int getIngredientSize()Getter for the amount of ingredients the recipe has -
getSlot
Getter for an ingredient slot- Parameters:
slot- integer of the slot (1-9)- Throws:
ArrayIndexOutOfBoundsException- if param is not 1-9
-
setPerm
Setter for the permission needed to craft the recipe- Parameters:
permission- the permission required
-
getPerm
Getter for the permission needed to craft the recipe, can be null -
hasPerm
public boolean hasPerm() -
addDisabledWorld
Adds a world to the noCraft list- Parameters:
world- the world to not allow crafting of the recipe in
-
getDisabledWorlds
-
setGrantItem
Sets whether the recipe output should be granted after a command is performed -
isGrantItem
public boolean isGrantItem()Gets whether the recipe output should be granted after a command is performed- Returns:
- true if the recipe is granted, false otherwise.
-
hasCommands
public boolean hasCommands()Gets whether the recipe is an item or a command- Returns:
- true if the recipe is a command, false otherwise
-
setCommands
-
getCommand
-