PaperMC/Spigot-API-Patches/0300-Add-basic-Datapack-API.patch

107 lines
3.1 KiB
Diff
Raw Normal View History

2021-05-16 22:09:46 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Connor Linfoot <connorlinfoot@me.com>
Date: Sun, 16 May 2021 15:07:34 +0100
Subject: [PATCH] Add basic Datapack API
diff --git a/src/main/java/io/papermc/paper/datapack/Datapack.java b/src/main/java/io/papermc/paper/datapack/Datapack.java
2021-05-16 22:09:46 +02:00
new file mode 100644
index 0000000000000000000000000000000000000000..7b2ab0be10a21e0496ad1d485ff8cb2c0b92a2cb
2021-05-16 22:09:46 +02:00
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datapack/Datapack.java
2021-05-16 22:09:46 +02:00
@@ -0,0 +1,32 @@
+package io.papermc.paper.datapack;
2021-05-16 22:09:46 +02:00
+
+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/datapack/DatapackManager.java b/src/main/java/io/papermc/paper/datapack/DatapackManager.java
2021-05-16 22:09:46 +02:00
new file mode 100644
index 0000000000000000000000000000000000000000..58f78d5e91beacaf710f62461cf869f70d08b2a2
2021-05-16 22:09:46 +02:00
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datapack/DatapackManager.java
2021-05-16 22:09:46 +02:00
@@ -0,0 +1,21 @@
+package io.papermc.paper.datapack;
2021-05-16 22:09:46 +02:00
+
+import org.checkerframework.checker.nullness.qual.NonNull;
+
+import java.util.Collection;
+
+public interface DatapackManager {
+
+ /**
+ * @return all the packs known to the server
+ */
+ @NonNull
+ Collection<Datapack> getPacks();
+
+ /**
+ * @return all the packs which are currently enabled
+ */
+ @NonNull
+ Collection<Datapack> getEnabledPacks();
+
+}
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 050ee6a6fd0b74d9bfdd9dfe88cd4cd3d17da868..a8b6cc350e85d4f1a31f30dee42feafd0edb6009 100644
2021-05-16 22:09:46 +02:00
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -1949,6 +1949,14 @@ public final class Bukkit {
2021-05-16 22:09:46 +02:00
public static com.destroystokyo.paper.entity.ai.MobGoals getMobGoals() {
return server.getMobGoals();
}
+
+ /**
+ * @return the datapack manager
2021-05-16 22:09:46 +02:00
+ */
+ @NotNull
+ public static io.papermc.paper.datapack.DatapackManager getDatapackManager() {
2021-05-16 22:09:46 +02:00
+ 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 eb7f604600839618eaf27e0e5444b4830716eb07..2b400079559abd6b847782ae8480f2ae1948e22a 100644
2021-05-16 22:09:46 +02:00
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1709,5 +1709,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
2021-05-16 22:09:46 +02:00
*/
@NotNull
com.destroystokyo.paper.entity.ai.MobGoals getMobGoals();
+
+ /**
+ * @return the datapack manager
2021-05-16 22:09:46 +02:00
+ */
+ @NotNull
+ io.papermc.paper.datapack.DatapackManager getDatapackManager();
2021-05-16 22:09:46 +02:00
// Paper end
}