Class Datapack

java.lang.Object
com.github.darksoulq.abyssallib.server.data.Datapack

@Experimental public class Datapack extends Object
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
    Constructor
    Description
    Datapack(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull String modid)
    Constructs a new Datapack instance associated with the specified plugin and mod ID.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Compiles the datapack by extracting files from the plugin JAR's /data/ directory, generating the pack.mcmeta, and writing all contents into a ZIP file.
    @NotNull Path
    Gets the output path of the compiled datapack ZIP file.
    void
    register(@NotNull net.kyori.adventure.text.Component title, io.papermc.paper.plugin.bootstrap.BootstrapContext ctx)
    Registers the datapack with Paper using BootstrapContext.

    Methods inherited from class Object

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

    • Datapack

      public Datapack(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull String modid)
      Constructs a new Datapack instance associated with the specified plugin and mod ID.
      Parameters:
      plugin - the plugin that owns this datapack
      modid - 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 the pack.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 using BootstrapContext. This method should be called during the PluginBootstrap#bootstrap phase.
      Parameters:
      title - the display title of the datapack in the UI
    • getOutputFile

      @NotNull public @NotNull Path getOutputFile()
      Gets the output path of the compiled datapack ZIP file.
      Returns:
      the path to the datapack ZIP file