Class RecipeLoader

java.lang.Object
com.github.darksoulq.abyssallib.world.recipe.RecipeLoader

public class RecipeLoader extends Object
A utility class for loading, parsing, and registering Minecraft recipes from external files.

This class supports standard Minecraft recipe types (Shaped, Shapeless, Furnace, etc.) as well as custom types. It uses a handler-based system to decode YAML data into Bukkit or library-specific recipe objects.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Functional interface for handling the conversion of raw YAML data into a recipe object.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    load(File file)
    Loads a single recipe file from the file system.
    static void
    Parses an input stream into one or more recipe definitions.
    static int
    loadFolder(File folder)
    Recursively scans a folder and loads all YAML files found as recipes.
    static int
    loadFolder(org.bukkit.plugin.Plugin plugin, String resourcePath)
    Loads recipes from a specific resource path within a plugin's JAR.
    static void
    loadResource(org.bukkit.plugin.Plugin plugin, String resourcePath)
    Loads a single recipe from a plugin resource.
    static void
    Registers a custom handler for a specific recipe type.
    static void
    Finalizes the recipe loading process by injecting all registered recipes into the Bukkit server.

    Methods inherited from class Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RecipeLoader

      public RecipeLoader()
  • Method Details

    • registerHandler

      public static void registerHandler(String type, RecipeLoader.RecipeHandler handler)
      Registers a custom handler for a specific recipe type.
      Parameters:
      type - The string identifier for the recipe type (e.g., "minecraft:shaped").
      handler - The RecipeLoader.RecipeHandler logic to process this type.
    • loadFolder

      public static int loadFolder(File folder)
      Recursively scans a folder and loads all YAML files found as recipes.
      Parameters:
      folder - The File directory to scan.
    • loadFolder

      public static int loadFolder(org.bukkit.plugin.Plugin plugin, String resourcePath)
      Loads recipes from a specific resource path within a plugin's JAR.
      Parameters:
      plugin - The Plugin instance.
      resourcePath - The internal path (e.g., "recipes/").
    • load

      public static void load(File file)
      Loads a single recipe file from the file system.
      Parameters:
      file - The YAML File.
    • loadResource

      public static void loadResource(org.bukkit.plugin.Plugin plugin, String resourcePath)
      Loads a single recipe from a plugin resource.
      Parameters:
      plugin - The Plugin owning the resource.
      resourcePath - The path to the file.
    • load

      public static void load(InputStream in) throws Codec.CodecException
      Parses an input stream into one or more recipe definitions.
      Parameters:
      in - The InputStream of the YAML content.
      Throws:
      Codec.CodecException - If parsing fails.
    • reload

      @Internal public static void reload()
      Finalizes the recipe loading process by injecting all registered recipes into the Bukkit server.

      This method iterates through all internal registries and calls Bukkit.addRecipe(Recipe) or adds potion mixes to the brewing system.