BlueGit

timfa copper-key

Files

copper-key / src / main / java / nl / timfalken / copperkeys / CopperKeysBootstrap.java

CopperKeysBootstrap.java

CopperKeysBootstrap.java 1.3 KiB Download Raw
1package nl.timfalken.copperkeys;
2
3import io.papermc.paper.datapack.DatapackRegistrar;
4import io.papermc.paper.plugin.bootstrap.BootstrapContext;
5import io.papermc.paper.plugin.bootstrap.PluginBootstrap;
6import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager;
7import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
8
9import java.io.IOException;
10import java.net.URI;
11import java.net.URISyntaxException;
12import java.util.Objects;
13
14public final class CopperKeysBootstrap implements PluginBootstrap {
15 @Override
16 public void bootstrap(BootstrapContext context) {
17 LifecycleEventManager<BootstrapContext> lifecycle = context.getLifecycleManager();
18 lifecycle.registerEventHandler(LifecycleEvents.DATAPACK_DISCOVERY, event -> {
19 DatapackRegistrar registrar = event.registrar();
20 try {
21 URI uri = Objects.requireNonNull(
22 CopperKeysBootstrap.class.getResource("/datapack"),
23 "Missing /datapack resources"
24 ).toURI();
25 registrar.discoverPack(uri, "advancements");
26 } catch (URISyntaxException | IOException ex) {
27 throw new RuntimeException("Failed to register CopperKeys datapack", ex);
28 }
29 });
30 }
31}