PaperMC/patches/api/0295-Add-basic-Datapack-API.patch
Nassim Jahnke 26734e83b0
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#7454)
* Updated Upstream (Bukkit/CraftBukkit/Spigot)

Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
8085edde SPIGOT-6918: Add SpawnCategory API and configurations for Axolotls
04c7e13c PR-719: Add Player Profile API
71564210 SPIGOT-6910: Add BlockDamageAbortEvent

CraftBukkit Changes:
febaa1c6 SPIGOT-6918: Add SpawnCategory API and configurations for Axolotls
9dafd109 Don't send updates over large distances
bdac46b0 SPIGOT-6782: EntityPortalEvent should not destroy entity when setTo() uses same world as getFrom()
8f361ece PR-1002: Add Player Profile API
911875d4 Increase outdated build delay
e5f8a767 SPIGOT-6917: Use main scoreboard for /trigger
a672a531 Clean up callBlockDamageEvent
8e1bdeef SPIGOT-6910: Add BlockDamageAbortEvent

Spigot Changes:
6edb62f3 Rebuild patches
7fbc6a1e Rebuild patches

* Updated Upstream (CraftBukkit)

Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

CraftBukkit Changes:
de951355 SPIGOT-6927: Fix default value of spawn-limits in Worlds
2022-02-12 14:20:33 +01:00

106 lines
3.1 KiB
Diff

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
new file mode 100644
index 0000000000000000000000000000000000000000..7b2ab0be10a21e0496ad1d485ff8cb2c0b92a2cb
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datapack/Datapack.java
@@ -0,0 +1,32 @@
+package io.papermc.paper.datapack;
+
+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
new file mode 100644
index 0000000000000000000000000000000000000000..58f78d5e91beacaf710f62461cf869f70d08b2a2
--- /dev/null
+++ b/src/main/java/io/papermc/paper/datapack/DatapackManager.java
@@ -0,0 +1,21 @@
+package io.papermc.paper.datapack;
+
+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 c8ea04b06d7178c6cc992a9a1b0355a70a035152..7732d26277ca8b845898cb01c7623a2f175f0aaa 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2238,6 +2238,14 @@ public final class Bukkit {
public static com.destroystokyo.paper.entity.ai.MobGoals getMobGoals() {
return server.getMobGoals();
}
+
+ /**
+ * @return the datapack manager
+ */
+ @NotNull
+ public static io.papermc.paper.datapack.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 67c6443c5639beafade19bc39932f30bf1001a8d..ca4a9428e89b084436ef43099974ae7684648776 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1961,5 +1961,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
@NotNull
com.destroystokyo.paper.entity.ai.MobGoals getMobGoals();
+
+ /**
+ * @return the datapack manager
+ */
+ @NotNull
+ io.papermc.paper.datapack.DatapackManager getDatapackManager();
// Paper end
}