Paper/patches/api/0283-Add-basic-Datapack-API.patch
Jake Potrebic de04cbced5
Updated Upstream (Bukkit/CraftBukkit) (#10034)
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:
f29cb801 Separate checkstyle-suppressions file is not required
86f99bbe SPIGOT-7540, PR-946: Add ServerTickManager API
d4119585 SPIGOT-6903, PR-945: Add BlockData#getMapColor
b7a2ed41 SPIGOT-7530, PR-947: Add Player#removeResourcePack
9dd56255 SPIGOT-7527, PR-944: Add WindCharge#explode()
994a6163 Attempt upgrade of resolver libraries

CraftBukkit Changes:
b3b43a6ad Add Checkstyle check for unused imports
13fb3358e SPIGOT-7544: Scoreboard#getEntries() doesn't get entries but class names
3dda99c06 SPIGOT-7540, PR-1312: Add ServerTickManager API
2ab4508c0 SPIGOT-6903, PR-1311: Add BlockData#getMapColor
1dbdbbed4 PR-1238: Remove unnecessary sign ticking
659728d2a MC-264285, SPIGOT-7439, PR-1237: Fix unbreakable flint and steel is completely consumed while igniting creeper
e37e29ce0 Increase outdated build delay
c00438b39 SPIGOT-7530, PR-1313: Add Player#removeResourcePack
492dd80ce SPIGOT-7527, PR-1310: Add WindCharge#explode()
e11fbb9d7 Upgrade MySQL driver
9f3a0bd2a Attempt upgrade of resolver libraries
60d16d7ca PR-1306: Centralize Bukkit and Minecraft entity conversion

Spigot Changes:
06d602e7 Rebuild patches
2023-12-16 18:09:28 -08:00

161 lines
5.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 c4a4a0b1295739070017e7d09dd5e04a798494e3..2e29da775e60c149d2c251d78ee7c60b494215a4 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -318,9 +318,11 @@ public final class Bukkit {
/**
* Get the DataPack Manager.
*
+ * @deprecated use {@link #getDatapackManager()}
* @return the manager
*/
@NotNull
+ @Deprecated(forRemoval = true)
public static DataPackManager getDataPackManager() {
return server.getDataPackManager();
}
@@ -2536,6 +2538,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 0e3e654fb0551c6f862ce14b75cf1186392b023f..61701b6e8291cb5816b0a7eb511152eed3db43e8 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -256,9 +256,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
/**
* Get the DataPack Manager.
*
+ * @deprecated use {@link #getDatapackManager()}
* @return the manager
*/
@NotNull
+ @Deprecated(forRemoval = true) // Paper
public DataPackManager getDataPackManager();
/**
@@ -2210,5 +2212,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
}
diff --git a/src/main/java/org/bukkit/packs/DataPack.java b/src/main/java/org/bukkit/packs/DataPack.java
index 3d5af25a399589f1bdf95b77f584ae0ae5c26f02..ab512c7ee9d2442055b719d02d0d0ecc7ea8d992 100644
--- a/src/main/java/org/bukkit/packs/DataPack.java
+++ b/src/main/java/org/bukkit/packs/DataPack.java
@@ -10,8 +10,10 @@ import org.jetbrains.annotations.NotNull;
* Represents a data pack.
*
* @see <a href="https://minecraft.wiki/w/Data_pack">Minecraft wiki</a>
+ * @deprecated use {@link io.papermc.paper.datapack.Datapack}
*/
@ApiStatus.Experimental
+@Deprecated(forRemoval = true) // Paper
public interface DataPack extends Keyed {
/**
diff --git a/src/main/java/org/bukkit/packs/DataPackManager.java b/src/main/java/org/bukkit/packs/DataPackManager.java
index d7fb6310e6b1050c496d748388310bc6f8d78e23..2cd505046277febe010e9476539b064321d8b2ec 100644
--- a/src/main/java/org/bukkit/packs/DataPackManager.java
+++ b/src/main/java/org/bukkit/packs/DataPackManager.java
@@ -11,8 +11,10 @@ import org.jetbrains.annotations.Nullable;
/**
* Manager of data packs.
+ * @deprecated use {@link io.papermc.paper.datapack.DatapackManager}
*/
@ApiStatus.Experimental
+@Deprecated(forRemoval = true) // Paper
public interface DataPackManager {
/**