Class Datapack
java.lang.Object
com.github.darksoulq.abyssallib.server.data.Datapack
Handles the loading, compilation, and registration of embedded datapacks from within a plugin JAR.
Files located under /data/ inside the plugin JAR are compiled into a ZIP file
located at <plugin>/pack/datapack.zip and registered using Paper's
DatapackRegistrar.
This class should be used during the PluginBootstrap#bootstrap phase.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcompile()Compiles the datapack by extracting files from the plugin JAR's/data/directory, generating thepack.mcmeta, and writing all contents into a ZIP file.@NotNull PathGets the output path of the compiled datapack ZIP file.voidregister(@NotNull net.kyori.adventure.text.Component title, io.papermc.paper.plugin.bootstrap.BootstrapContext ctx) Registers the datapack with Paper usingBootstrapContext.
-
Constructor Details
-
Datapack
Constructs a newDatapackinstance associated with the specified plugin and mod ID.- Parameters:
plugin- the plugin that owns this datapackmodid- the namespace or mod ID for this datapack
-
-
Method Details
-
compile
public void compile()Compiles the datapack by extracting files from the plugin JAR's/data/directory, generating thepack.mcmeta, and writing all contents into a ZIP file.- Throws:
RuntimeException- if an I/O error occurs during processing
-
register
public void register(@NotNull @NotNull net.kyori.adventure.text.Component title, io.papermc.paper.plugin.bootstrap.BootstrapContext ctx) Registers the datapack with Paper usingBootstrapContext. This method should be called during thePluginBootstrap#bootstrapphase.- Parameters:
title- the display title of the datapack in the UI
-
getOutputFile
Gets the output path of the compiled datapack ZIP file.- Returns:
- the path to the datapack ZIP file
-