Class RecipeUtil.Recipe

java.lang.Object
me.mehboss.utils.RecipeUtil.Recipe
Direct Known Subclasses:
BrewingRecipeData, CookingRecipeData, CraftingRecipeData, WorkstationRecipeData
Enclosing class:
RecipeUtil

public static class RecipeUtil.Recipe extends Object
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.

  • Constructor Details

    • Recipe

      public Recipe(String name)
      Parameterized constructor. Initializes a Recipe object with specified name
      Parameters:
      name - the name of the recipe
  • Method Details

    • getBookCategory

      public String getBookCategory()
      Getter for setBookCategory
      Returns:
      the Category enum the recipe belongs to in the recipe book.
    • setBookCategory

      public void setBookCategory(String category)
      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

      public void setDiscoverable(Boolean discoverable)
      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

      public void setCustomItem(String customItem)
      Sets an ID for custom item results
      Parameters:
      customItem - the ID of the custom item
    • getCustomItemID

      public String getCustomItemID()
      Getter for the custom ID output
      Returns:
      the customItem ID
    • isExactChoice

      public boolean isExactChoice()
      Getter for setExactChoice
      Returns:
      true if the recipe is exactChoice, false otherwise.
    • setExactChoice

      public void setExactChoice(Boolean exactChoice)
      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

      public void setPlaceable(Boolean placeable)
      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

      public void setActive(Boolean status)
      Enables or disables a recipe
      Parameters:
      status - true or false boolean
    • getName

      public String getName()
      Getter for the recipe name
      Returns:
      what the recipe name is
    • setRow

      public void setRow(int row, String shape)
      Setter for the shaped recipe rows, required
      Parameters:
      row - the recipe row
      shape - the shape for the row (example: XDX)
      Throws:
      ArrayIndexOutOfBoundsException - if the integer specified is not rows 1-3
    • getRow

      public String getRow(int row)
      Getter for the shaped recipe rows
      Parameters:
      row - the recipe row
      Throws:
      ArrayIndexOutOfBoundsException - if the integer specified is not rows 1-3
    • setType

      public void setType(RecipeUtil.Recipe.RecipeType type)
      Setter for the RecipeType, not required and defaults to SHAPED
      Parameters:
      SHAPELESS - the recipe type will be shapeless
      SHAPED - the recipe type will be shaped
      FURNACE - the recipe type will be a furnace recipe
      STONECUTTER - the recipe type will be a stonecutter recipe
    • getType

      public RecipeUtil.Recipe.RecipeType 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 null
      InvalidRecipeException - 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

      public void setKey(String key)
      Setter for the NamedspaceKey, required
      Parameters:
      key - the NamedspaceKey
    • getKey

      public String 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

      public void addIngredient(RecipeUtil.Ingredient ingredient)
      Adds an Ingredient object to the recipe, required Requires 9 ingredients for crafting, 1 otherwise
      Parameters:
      ingredient - a finalized Ingredient for the recipe
    • getAllIngredientTypes

      public ArrayList<org.bukkit.Material> getAllIngredientTypes()
      Compiles all ingredient materials of a recipe
    • getIngredients

      public ArrayList<RecipeUtil.Ingredient> getIngredients()
      Getter for the recipe ingredients
    • getIngredientSize

      public int getIngredientSize()
      Getter for the amount of ingredients the recipe has
    • getSlot

      public RecipeUtil.Ingredient getSlot(int slot) throws ArrayIndexOutOfBoundsException
      Getter for an ingredient slot
      Parameters:
      slot - integer of the slot (1-9)
      Throws:
      ArrayIndexOutOfBoundsException - if param is not 1-9
    • setPerm

      public void setPerm(String permission)
      Setter for the permission needed to craft the recipe
      Parameters:
      permission - the permission required
    • getPerm

      public String getPerm()
      Getter for the permission needed to craft the recipe, can be null
    • hasPerm

      public boolean hasPerm()
    • addDisabledWorld

      public void addDisabledWorld(String world)
      Adds a world to the noCraft list
      Parameters:
      world - the world to not allow crafting of the recipe in
    • getDisabledWorlds

      public ArrayList<String> getDisabledWorlds()
      Getter for worlds the recipe can not be crafted in
    • setGrantItem

      public void setGrantItem(Boolean grantItem)
      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

      public void setCommands(List<String> commands)
      Sets the commands to perform upon crafting a recipe
      Parameters:
      commands - the list of command strings
    • getCommand

      public List<String> getCommand()
      Gets the commands to perform upon crafting a recipe
      Returns:
      the list of commands to be performed