Folia/patches/api/0003-Require-plugins-to-be-explicitly-marked-as-Folia-sup.patch
2023-07-06 22:26:45 -07:00

83 lines
3.5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Mon, 6 Mar 2023 13:14:06 -0800
Subject: [PATCH] Require plugins to be explicitly marked as Folia supported
Plugins must add "folia-supported: true" to their plugin.yml
otherwise the server will refuse to load them.
Since Folia is a major breakage for plugins, the vast majority
of plugins will not function correctly on Folia. To prevent
user confusion from this, we will refuse to load the plugin
and provide a log indicating why - which will be much
more helpful than some random error log caused by
a breakage.
diff --git a/src/main/java/io/papermc/paper/plugin/configuration/PluginMeta.java b/src/main/java/io/papermc/paper/plugin/configuration/PluginMeta.java
index ef393f1f93ca48264fc1b6e3a27787f6a9152e1b..1325f9fed80731b74b80145dadc843b1a34b851b 100644
--- a/src/main/java/io/papermc/paper/plugin/configuration/PluginMeta.java
+++ b/src/main/java/io/papermc/paper/plugin/configuration/PluginMeta.java
@@ -200,4 +200,12 @@ public interface PluginMeta {
@Nullable
String getAPIVersion();
+ // Folia start - block plugins not marked as supported
+ /**
+ * Returns whether the plugin has been marked to be compatible with regionised threading as provided
+ * by Folia
+ */
+ public boolean isFoliaSupported();
+ // Folia end - block plugins not marked as supported
+
}
diff --git a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
index 07e8908d25fcd4e5eabadc9f019b54acff3b5e3c..02ab82f6d0eb2a5afbb6b0ac4d738097c4986ad1 100644
--- a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
+++ b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
@@ -258,6 +258,21 @@ public final class PluginDescriptionFile implements io.papermc.paper.plugin.conf
private Set<PluginAwareness> awareness = ImmutableSet.of();
private String apiVersion = null;
private List<String> libraries = ImmutableList.of();
+
+ // Folia start - block plugins not marked as supported
+ private String foliaSupported;
+ private static final String FOLIA_SUPPORTED_KEY = "folia-supported";
+
+ /**
+ * Returns whether the plugin has been marked to be compatible with regionised threading as provided
+ * by Folia
+ */
+ @Override
+ public boolean isFoliaSupported() {
+ return this.foliaSupported != null && this.foliaSupported.equalsIgnoreCase("true");
+ }
+ // Folia end - block plugins not marked as supported
+
// Paper start - oh my goddddd
/**
* Don't use this.
@@ -1241,6 +1256,11 @@ public final class PluginDescriptionFile implements io.papermc.paper.plugin.conf
if (map.get("prefix") != null) {
prefix = map.get("prefix").toString();
}
+ // Folia start - block plugins not marked as supported
+ if (map.get(FOLIA_SUPPORTED_KEY) != null) {
+ foliaSupported = map.get(FOLIA_SUPPORTED_KEY).toString();
+ }
+ // Folia end - block plugins not marked as supported
}
@NotNull
@@ -1317,6 +1337,11 @@ public final class PluginDescriptionFile implements io.papermc.paper.plugin.conf
if (prefix != null) {
map.put("prefix", prefix);
}
+ // Folia start - block plugins not marked as supported
+ if (foliaSupported != null) {
+ map.put(FOLIA_SUPPORTED_KEY, foliaSupported);
+ }
+ // Folia end - block plugins not marked as supported
return map;
}