From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Connor Linfoot Date: Sun, 16 May 2021 15:07:34 +0100 Subject: [PATCH] Add basic Datapack API diff --git a/src/main/java/io/papermc/paper/resource/Datapack.java b/src/main/java/io/papermc/paper/resource/Datapack.java new file mode 100644 index 0000000000000000000000000000000000000000..5233057bf1ee10da28d7c3b9c36665616650b1ea --- /dev/null +++ b/src/main/java/io/papermc/paper/resource/Datapack.java @@ -0,0 +1,32 @@ +package io.papermc.paper.resource; + +import org.checkerframework.checker.nullness.qual.NonNull; + +public interface Datapack { + + /** + * @return the name of the pack + */ + @NonNull + String getName(); + + /** + * @return the compatibility of the pack + */ + @NonNull + Compatibility getCompatibility(); + + /** + * @return whether or not the pack is currently enabled + */ + boolean isEnabled(); + + void setEnabled(boolean enabled); + + enum Compatibility { + TOO_OLD, + TOO_NEW, + COMPATIBLE, + } + +} diff --git a/src/main/java/io/papermc/paper/resource/DatapackManager.java b/src/main/java/io/papermc/paper/resource/DatapackManager.java new file mode 100644 index 0000000000000000000000000000000000000000..b404e1a0d0afbf6297cc0c2623696fac26bcbc08 --- /dev/null +++ b/src/main/java/io/papermc/paper/resource/DatapackManager.java @@ -0,0 +1,21 @@ +package io.papermc.paper.resource; + +import org.checkerframework.checker.nullness.qual.NonNull; + +import java.util.Collection; + +public interface DatapackManager { + + /** + * @return all the packs known to the server + */ + @NonNull + Collection getPacks(); + + /** + * @return all the packs which are currently enabled + */ + @NonNull + Collection getEnabledPacks(); + +} diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java index 5f7208196684d9c8373df28b7cfb5f9e21baa41e..bd834cd9b1d05327da195b76719e90ac14943dbb 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -1937,6 +1937,14 @@ public final class Bukkit { public static com.destroystokyo.paper.entity.ai.MobGoals getMobGoals() { return server.getMobGoals(); } + + /** + * @return the resource pack manager + */ + @NotNull + public static io.papermc.paper.resource.DatapackManager getDatapackManager() { + return server.getDatapackManager(); + } // Paper end @NotNull diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java index f3e27d2d02a9407bb1b091b8c1125ad5abf99e55..5f2b9a91b03a3e8b2dc5ce7743e31bea882500e4 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -1698,5 +1698,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi */ @NotNull com.destroystokyo.paper.entity.ai.MobGoals getMobGoals(); + + /** + * @return the resource pack manager + */ + @NotNull + io.papermc.paper.resource.DatapackManager getDatapackManager(); // Paper end }