From 5c4d65efb8d65863a97d98d526a681a3a99bfc41 Mon Sep 17 00:00:00 2001 From: Spottedleaf Date: Mon, 6 Mar 2023 14:02:11 -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. --- ...to-be-explicitly-marked-as-Folia-sup.patch | 66 +++++++++++++++++++ patches/server/0004-Threaded-Regions.patch | 17 +++++ 2 files changed, 83 insertions(+) create mode 100644 patches/api/0003-Require-plugins-to-be-explicitly-marked-as-Folia-sup.patch diff --git a/patches/api/0003-Require-plugins-to-be-explicitly-marked-as-Folia-sup.patch b/patches/api/0003-Require-plugins-to-be-explicitly-marked-as-Folia-sup.patch new file mode 100644 index 0000000..8832429 --- /dev/null +++ b/patches/api/0003-Require-plugins-to-be-explicitly-marked-as-Folia-sup.patch @@ -0,0 +1,66 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Spottedleaf +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/org/bukkit/plugin/PluginDescriptionFile.java b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java +index 0c9f4d1e9104fa6951114c1f9ec954dfcc749196..fc11577083672f127335613459436167d339efa4 100644 +--- a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java ++++ b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java +@@ -254,6 +254,17 @@ public final class PluginDescriptionFile { + private Set awareness = ImmutableSet.of(); + private String apiVersion = null; + private List libraries = ImmutableList.of(); ++ // Folia start - block plugins not marked as supported ++ private boolean foliaSupported; ++ ++ /** ++ * Returns whether the plugin has been marked to be compatible with regionised threading as provided ++ * by Folia ++ */ ++ public boolean isFoliaSupported() { ++ return foliaSupported; ++ } ++ // Folia end - block plugins not marked as supported + + public PluginDescriptionFile(@NotNull final InputStream stream) throws InvalidDescriptionException { + loadMap(asMap(YAML.get().load(stream))); +@@ -1173,6 +1184,11 @@ public final class PluginDescriptionFile { + if (map.get("prefix") != null) { + prefix = map.get("prefix").toString(); + } ++ // Folia start - block plugins not marked as supported ++ if (map.get("folia-supported") != null) { ++ foliaSupported = map.get("folia-supported").toString().equalsIgnoreCase("true"); ++ } ++ // Folia end - block plugins not marked as supported + } + + @NotNull +diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java +index 499dc8309a16b33d16b57b433c3c5b4330323717..25f228e616d1f5475a06bf3eeb2cf1cf6b6ed352 100644 +--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java ++++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java +@@ -163,6 +163,12 @@ public final class SimplePluginManager implements PluginManager { + server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + file.getParentFile().getPath() + "': uses the space-character (0x20) in its name"); // Paper + continue; + } ++ // Folia start - block plugins not marked as supported ++ if (!description.isFoliaSupported()) { ++ server.getLogger().log(Level.SEVERE, "Could not load plugin '" + name + "' as it is not marked as supporting Folia!"); ++ continue; ++ } ++ // Folia end - block plugins not marked as supported + } catch (InvalidDescriptionException ex) { + server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + file.getParentFile().getPath() + "'", ex); // Paper + continue; diff --git a/patches/server/0004-Threaded-Regions.patch b/patches/server/0004-Threaded-Regions.patch index b9b014e..2fe00e1 100644 --- a/patches/server/0004-Threaded-Regions.patch +++ b/patches/server/0004-Threaded-Regions.patch @@ -22212,6 +22212,23 @@ index cdefb2025eedea7e204d70d568adaf1c1ec4c03c..9136fb30db749737e9f189d0901024fc // Paper start if (!this.isAsyncScheduler && !task.isSync()) { this.asyncScheduler.handle(task, delay); +diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +index daeaa30cdd64f5cb775304e82f2390684c02a9d3..829c44a4a1289de5b035f405a018c9d375f44e8c 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +@@ -372,6 +372,12 @@ public final class CraftMagicNumbers implements UnsafeValues { + String minimumVersion = MinecraftServer.getServer().server.minimumAPI; + int minimumIndex = CraftMagicNumbers.SUPPORTED_API.indexOf(minimumVersion); + ++ // Folia start - block plugins not marked as supported ++ if (!pdf.isFoliaSupported()) { ++ throw new InvalidPluginException("Plugin " + pdf.getFullName() + " is not marked as supporting regionised multithreading"); ++ } ++ // Folia end - block plugins not marked as supported ++ + if (pdf.getAPIVersion() != null) { + int pluginIndex = CraftMagicNumbers.SUPPORTED_API.indexOf(pdf.getAPIVersion()); + diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java index e881584d38dc354204479863f004e974a0ac6c07..7d99ba41a3178f5321403eb7749f0a4b898ad0a9 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java