Class StructureLoader
java.lang.Object
com.github.darksoulq.abyssallib.world.structure.StructureLoader
Manages the loading, saving, and registration of serialized structure files.
This class scans the
structures/ directory and automatically registers
valid JSON and compressed structural files into the Registries.STRUCTURES registry.
It relies on namespaced subfolders to determine the unique Key for each structure.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidload()Initializes the structure folder and performs a recursive scan for valid files.static StructureLoads and deserializes a structure from a specific file path on the disk.static StructureloadResource(org.bukkit.plugin.Plugin plugin, String resourcePath) Loads a structure embedded within a plugin's internal JAR resources.static booleanSerializes and saves a structure to the disk using the specified identifier.
-
Constructor Details
-
StructureLoader
public StructureLoader()
-
-
Method Details
-
load
public static void load()Initializes the structure folder and performs a recursive scan for valid files. Found files ending in.structor.jsonare processed and automatically registered into the internal structure registry. -
load
Loads and deserializes a structure from a specific file path on the disk. Supports both raw JSON files and GZIP compressed.structfiles. -
loadResource
Loads a structure embedded within a plugin's internal JAR resources. Supports both raw JSON files and GZIP compressed.structfiles.- Parameters:
plugin- ThePlugininstance owning the internal resource.resourcePath- The internal String path within the JAR (e.g., "assets/myplugin/structures/house.json").- Returns:
- The deserialized
Structureinstance, or null if the resource is missing or invalid.
-
save
Serializes and saves a structure to the disk using the specified identifier. The file is automatically saved atstructures/<namespace>/<path>.structutilizing GZIP compression to minimize disk footprint.- Parameters:
id- TheKeydefining the namespace and file name layout.structure- TheStructureinstance to serialize and save.- Returns:
- True if the I/O write operation was successful, false otherwise.
-