Class ShapedRecipe

java.lang.Object
org.bukkit.inventory.CraftingRecipe
org.bukkit.inventory.ShapedRecipe
All Implemented Interfaces:
Recipe, Keyed

public class ShapedRecipe extends CraftingRecipe
Represents a shaped (ie normal) crafting recipe.
  • Constructor Details

  • Method Details

    • shape

      @NotNull public ShapedRecipe shape(@NotNull String... shape)
      Set the shape of this recipe to the specified rows. Each character represents a different ingredient; excluding space characters, which must be empty, exactly what each character represents is set separately. The first row supplied corresponds with the upper most part of the recipe on the workbench e.g. if all three rows are supplies the first string represents the top row on the workbench.
      Parameters:
      shape - The rows of the recipe (up to 3 rows).
      Returns:
      The changed recipe, so you can chain calls.
    • setIngredient

      @NotNull public ShapedRecipe setIngredient(char key, @NotNull MaterialData ingredient)
      Sets the material that a character in the recipe shape refers to.

      Note that before an ingredient can be set, the recipe's shape must be defined with shape(String...).

      Parameters:
      key - The character that represents the ingredient in the shape.
      ingredient - The ingredient.
      Returns:
      The changed recipe, so you can chain calls.
      Throws:
      IllegalArgumentException - if the key is a space character
      IllegalArgumentException - if the key does not appear in the shape.
    • setIngredient

      @NotNull public ShapedRecipe setIngredient(char key, @NotNull Material ingredient)
      Sets the material that a character in the recipe shape refers to.

      Note that before an ingredient can be set, the recipe's shape must be defined with shape(String...).

      Parameters:
      key - The character that represents the ingredient in the shape.
      ingredient - The ingredient.
      Returns:
      The changed recipe, so you can chain calls.
      Throws:
      IllegalArgumentException - if the key is a space character
      IllegalArgumentException - if the key does not appear in the shape.
    • setIngredient

      @Deprecated @NotNull public ShapedRecipe setIngredient(char key, @NotNull Material ingredient, int raw)
      Deprecated.
      Magic value
      Sets the material that a character in the recipe shape refers to.

      Note that before an ingredient can be set, the recipe's shape must be defined with shape(String...).

      Parameters:
      key - The character that represents the ingredient in the shape.
      ingredient - The ingredient.
      raw - The raw material data as an integer.
      Returns:
      The changed recipe, so you can chain calls.
      Throws:
      IllegalArgumentException - if the key is a space character
      IllegalArgumentException - if the key does not appear in the shape.
    • setIngredient

      @NotNull public ShapedRecipe setIngredient(char key, @NotNull RecipeChoice ingredient)
      Sets the RecipeChoice that a character in the recipe shape refers to.

      Note that before an ingredient can be set, the recipe's shape must be defined with shape(String...).

      Parameters:
      key - The character that represents the ingredient in the shape.
      ingredient - The ingredient.
      Returns:
      The changed recipe, so you can chain calls.
      Throws:
      IllegalArgumentException - if the key is a space character
      IllegalArgumentException - if the key does not appear in the shape.
    • getIngredientMap

      @NotNull public Map<Character,ItemStack> getIngredientMap()
      Get a copy of the ingredients map.
      Returns:
      The mapping of character to ingredients.
    • getChoiceMap

      @NotNull public Map<Character,RecipeChoice> getChoiceMap()
      Get a copy of the choice map.
      Returns:
      The mapping of character to ingredients.
    • getShape

      @NotNull public String[] getShape()
      Get the shape.
      Returns:
      The recipe's shape.
      Throws:
      NullPointerException - when not set yet