java.lang.Object
io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters.AbstractRecipe

public abstract class AbstractRecipe extends Object
This class abstracts away from concrete recipes. It supports ShapedRecipe, ShapelessRecipe and recipes made using the EnhancedCraftingTable.
Author:
TheBusyBiscuit
See Also:
  • Constructor Details

    • AbstractRecipe

      @ParametersAreNonnullByDefault protected AbstractRecipe(Collection<Predicate<org.bukkit.inventory.ItemStack>> ingredients, org.bukkit.inventory.ItemStack result)
      Protected constructor. For implementation classes only.
      Parameters:
      ingredients - The ingredients for this recipe as predicates
      result - The resulting ItemStack
  • Method Details

    • getIngredients

      @Nonnull public Collection<Predicate<org.bukkit.inventory.ItemStack>> getIngredients()
      This returns the Collection of ingredients as Predicates.
      Returns:
      The ingredients for this AbstractRecipe
    • getResult

      @Nonnull public org.bukkit.inventory.ItemStack getResult()
      This returns the result of this AbstractRecipe. This will return the original ItemStack, so make sure to ItemStack.clone() it.
      Returns:
      The resulting ItemStack
    • isEnabled

      public boolean isEnabled()
      This returns whether or not this recipe has been enabled. A disabled recipe will not be crafted.
      Returns:
      Whether this recipe is enabled
    • setEnabled

      public void setEnabled(boolean enabled)
      This method enables or disables this recipe. A disabled recipe will not be crafted.
      Parameters:
      enabled - Whether this recipe is enabled
    • show

      public abstract void show(@Nonnull ChestMenu menu, @Nonnull AsyncRecipeChoiceTask task)
      This will visually represent this AbstractRecipe in the given ChestMenu. Any RecipeChoice.MaterialChoice will be cycled through using the AsyncRecipeChoiceTask.
      Parameters:
      menu - The ChestMenu to display the recipe in
      task - The AsyncRecipeChoiceTask instance
    • of

      @Nullable public static AbstractRecipe of(@Nullable org.bukkit.inventory.Recipe recipe)
      This is our static accessor for the AbstractRecipe class. It will create a new VanillaRecipe for the given Recipe if it is a valid Recipe.

      Currently supported recipe types are ShapedRecipe and ShapelessRecipe. If the Recipe is null or none of the aforementioned types, null will be returned.

      Parameters:
      recipe - The Recipe to wrap
      Returns:
      The wrapped AbstractRecipe or null
    • of

      @Nullable public static AbstractRecipe of(@Nullable SlimefunItem item, @Nonnull RecipeType recipeType)
      This static accessor is for SlimefunItem recipes. Note that the SlimefunItem must be crafted using the specified RecipeType, otherwise null will be returned.
      Parameters:
      item - The SlimefunItem the recipe belongs to
      recipeType - The RecipeType
      Returns:
      The wrapped AbstractRecipe or null