Class TagLoader

java.lang.Object
com.github.darksoulq.abyssallib.world.data.tag.TagLoader

public class TagLoader extends Object
A utility class responsible for loading, parsing, and registering data tags from external files.

This loader supports deep directory scanning and can parse both JSON and YAML file formats. Files must define a type (to resolve the TagType and its codec) and an id (to register the instantiated Tag into the central registry). It automatically handles appending data to existing tags and recursively resolving cross-tag inclusions, unless the replace boolean field is set to true, which will completely override previous entries.

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    loadFile(File file)
    Loads a single tag definition from the local file system.
    static int
    loadFolder(File folder)
    Recursively scans a system folder and loads all JSON and YAML files found as tags.
    static int
    loadFolder(org.bukkit.plugin.Plugin plugin, String resourcePath)
    Deeply scans and loads tags from a specific resource path within a plugin's embedded JAR file.
    static void
    loadResource(org.bukkit.plugin.Plugin plugin, String resourcePath)
    Loads a single tag definition from an internal plugin resource.
    static void
    Finalizes the tag loading phase by binding interdependent inclusions.

    Methods inherited from class Object

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

    • TagLoader

      public TagLoader()
  • Method Details

    • loadFolder

      public static int loadFolder(File folder)
      Recursively scans a system folder and loads all JSON and YAML files found as tags.
      Parameters:
      folder - The root File directory to scan.
      Returns:
      The total number of tag files successfully processed.
    • loadFolder

      public static int loadFolder(org.bukkit.plugin.Plugin plugin, String resourcePath)
      Deeply scans and loads tags from a specific resource path within a plugin's embedded JAR file.
      Parameters:
      plugin - The Plugin instance owning the resources.
      resourcePath - The internal path directory (e.g., "tags/").
      Returns:
      The total number of tag resources successfully processed.
    • loadFile

      public static void loadFile(File file)
      Loads a single tag definition from the local file system.
      Parameters:
      file - The File to read.
    • loadResource

      public static void loadResource(org.bukkit.plugin.Plugin plugin, String resourcePath)
      Loads a single tag definition from an internal plugin resource.
      Parameters:
      plugin - The Plugin holding the resource.
      resourcePath - The relative path to the resource file.
    • resolveIncludes

      public static void resolveIncludes()
      Finalizes the tag loading phase by binding interdependent inclusions.

      Iterates through all parsed "includes" lists to dynamically link parent and child tags. Any unresolved or mismatched types are logged as warnings.