2021-06-11 14:02:28 +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
|
|
|
|
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
|
2024-09-07 22:35:11 +02:00
|
|
|
index b558fa73dbcf3747690933e6aadf7061a0de2630..be68351555bde59a4e55bf1bad261e9f6bc9f704 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
|
|
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
2024-06-13 17:45:43 +02:00
|
|
|
@@ -328,9 +328,11 @@ public final class Bukkit {
|
2023-06-06 11:09:19 +02:00
|
|
|
/**
|
|
|
|
* Get the DataPack Manager.
|
|
|
|
*
|
|
|
|
+ * @deprecated use {@link #getDatapackManager()}
|
|
|
|
* @return the manager
|
|
|
|
*/
|
|
|
|
@NotNull
|
2024-09-07 22:35:11 +02:00
|
|
|
+ @Deprecated(forRemoval = true, since = "1.20")
|
2023-06-06 11:09:19 +02:00
|
|
|
public static DataPackManager getDataPackManager() {
|
|
|
|
return server.getDataPackManager();
|
|
|
|
}
|
2024-08-19 11:41:55 +02:00
|
|
|
@@ -2617,6 +2619,14 @@ public final class Bukkit {
|
2021-06-11 14:02:28 +02:00
|
|
|
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
|
2024-09-07 22:35:11 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java
|
|
|
|
index cc25734f3dcf6075eb44e39da01ed2f1b59b618e..2721ad40d6ba025caad16455f74f2350dcb7a4ff 100644
|
|
|
|
--- a/src/main/java/org/bukkit/Material.java
|
|
|
|
+++ b/src/main/java/org/bukkit/Material.java
|
|
|
|
@@ -5497,6 +5497,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla
|
|
|
|
* @param world the world to check
|
|
|
|
* @return true if this material can be used in this World.
|
|
|
|
*/
|
|
|
|
+ @Deprecated(forRemoval = true, since = "1.20") // Paper
|
|
|
|
public boolean isEnabledByFeature(@NotNull World world) {
|
|
|
|
if (isItem()) {
|
|
|
|
return Bukkit.getDataPackManager().isEnabledByFeature(asItemType(), world);
|
2021-06-11 14:02:28 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
2024-09-07 22:35:11 +02:00
|
|
|
index 42930006b6425b5d82233e4ffe7025ce5397b277..45693e6c02eac37eb609cd3c59253a949a6ca4c0 100644
|
2021-06-11 14:02:28 +02:00
|
|
|
--- a/src/main/java/org/bukkit/Server.java
|
|
|
|
+++ b/src/main/java/org/bukkit/Server.java
|
2024-06-13 17:45:43 +02:00
|
|
|
@@ -267,9 +267,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
2023-06-06 11:09:19 +02:00
|
|
|
/**
|
|
|
|
* Get the DataPack Manager.
|
|
|
|
*
|
|
|
|
+ * @deprecated use {@link #getDatapackManager()}
|
|
|
|
* @return the manager
|
|
|
|
*/
|
|
|
|
@NotNull
|
2024-09-07 22:35:11 +02:00
|
|
|
+ @Deprecated(forRemoval = true, since = "1.20") // Paper
|
2023-06-06 11:09:19 +02:00
|
|
|
public DataPackManager getDataPackManager();
|
|
|
|
|
|
|
|
/**
|
2024-08-19 11:41:55 +02:00
|
|
|
@@ -2284,5 +2286,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
2021-06-11 14:02:28 +02:00
|
|
|
*/
|
|
|
|
@NotNull
|
|
|
|
com.destroystokyo.paper.entity.ai.MobGoals getMobGoals();
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @return the datapack manager
|
|
|
|
+ */
|
|
|
|
+ @NotNull
|
|
|
|
+ io.papermc.paper.datapack.DatapackManager getDatapackManager();
|
|
|
|
// Paper end
|
|
|
|
}
|
2024-09-07 22:35:11 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/entity/EntityType.java b/src/main/java/org/bukkit/entity/EntityType.java
|
|
|
|
index 976f701ed9b9873945a5628173c580e2e6873864..eea0351559a2835280713f5d5d1d430c7cf857a0 100644
|
|
|
|
--- a/src/main/java/org/bukkit/entity/EntityType.java
|
|
|
|
+++ b/src/main/java/org/bukkit/entity/EntityType.java
|
|
|
|
@@ -449,6 +449,7 @@ public enum EntityType implements Keyed, Translatable, net.kyori.adventure.trans
|
|
|
|
* @param world the world to check
|
|
|
|
* @return true if this EntityType can be used to spawn an Entity for this World.
|
|
|
|
*/
|
|
|
|
+ @Deprecated(forRemoval = true, since = "1.20") // Paper
|
|
|
|
public boolean isEnabledByFeature(@NotNull World world) {
|
|
|
|
return Bukkit.getDataPackManager().isEnabledByFeature(this, world);
|
|
|
|
}
|
2023-06-06 11:09:19 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/packs/DataPack.java b/src/main/java/org/bukkit/packs/DataPack.java
|
2024-09-07 22:35:11 +02:00
|
|
|
index ea03c51d51e015e69d3aaa795547033ceabff9e0..f51d59e6369c76e333fd9e58e711c2b6f245882d 100644
|
2023-06-06 11:09:19 +02:00
|
|
|
--- a/src/main/java/org/bukkit/packs/DataPack.java
|
|
|
|
+++ b/src/main/java/org/bukkit/packs/DataPack.java
|
2024-06-13 17:45:43 +02:00
|
|
|
@@ -9,7 +9,9 @@ import org.jetbrains.annotations.NotNull;
|
2023-06-06 11:09:19 +02:00
|
|
|
* Represents a data pack.
|
2023-09-29 02:28:26 +02:00
|
|
|
*
|
|
|
|
* @see <a href="https://minecraft.wiki/w/Data_pack">Minecraft wiki</a>
|
2023-06-06 11:09:19 +02:00
|
|
|
+ * @deprecated use {@link io.papermc.paper.datapack.Datapack}
|
|
|
|
*/
|
2024-09-07 22:35:11 +02:00
|
|
|
+@Deprecated(forRemoval = true, since = "1.20") // Paper
|
2023-06-06 11:09:19 +02:00
|
|
|
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
|
2024-09-07 22:35:11 +02:00
|
|
|
index aee6e828c6fac9b010356af1239a58b4579c1773..1b850e76a885f0da653d4b48db72e5f85ae72805 100644
|
2023-06-06 11:09:19 +02:00
|
|
|
--- a/src/main/java/org/bukkit/packs/DataPackManager.java
|
|
|
|
+++ b/src/main/java/org/bukkit/packs/DataPackManager.java
|
2024-06-13 17:45:43 +02:00
|
|
|
@@ -13,7 +13,9 @@ import org.jetbrains.annotations.Nullable;
|
2023-06-06 11:09:19 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Manager of data packs.
|
|
|
|
+ * @deprecated use {@link io.papermc.paper.datapack.DatapackManager}
|
|
|
|
*/
|
2024-09-07 22:35:11 +02:00
|
|
|
+@Deprecated(forRemoval = true, since = "1.20") // Paper
|
2023-06-06 11:09:19 +02:00
|
|
|
public interface DataPackManager {
|
|
|
|
|
|
|
|
/**
|