package nl.timfalken.copperkeys; import io.papermc.paper.datapack.DatapackRegistrar; import io.papermc.paper.plugin.bootstrap.BootstrapContext; import io.papermc.paper.plugin.bootstrap.PluginBootstrap; import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager; import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.Objects; public final class CopperKeysBootstrap implements PluginBootstrap { @Override public void bootstrap(BootstrapContext context) { LifecycleEventManager lifecycle = context.getLifecycleManager(); lifecycle.registerEventHandler(LifecycleEvents.DATAPACK_DISCOVERY, event -> { DatapackRegistrar registrar = event.registrar(); try { URI uri = Objects.requireNonNull( CopperKeysBootstrap.class.getResource("/datapack"), "Missing /datapack resources" ).toURI(); registrar.discoverPack(uri, "advancements"); } catch (URISyntaxException | IOException ex) { throw new RuntimeException("Failed to register CopperKeys datapack", ex); } }); } }