Support paper plugin meta marking plugins as Folia supported

This commit is contained in:
Owen1212055 2023-03-29 14:12:30 -07:00 committed by Spottedleaf
parent 7ce0308bdb
commit 32f79c415e
2 changed files with 86 additions and 21 deletions

View File

@ -13,11 +13,28 @@ 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 028805bcdb1d2bb0d11387db165b7376579e5f60..51bc04571f75a4ccf05c3d080531a29fe35817d1 100644
index 028805bcdb1d2bb0d11387db165b7376579e5f60..7bc31036a612df6088a7bb190ed16d0cdbfeaccc 100644
--- a/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
+++ b/src/main/java/org/bukkit/plugin/PluginDescriptionFile.java
@@ -255,6 +255,20 @@ public final class PluginDescriptionFile implements io.papermc.paper.plugin.conf
@@ -255,6 +255,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();
@ -30,6 +47,7 @@ index 028805bcdb1d2bb0d11387db165b7376579e5f60..51bc04571f75a4ccf05c3d080531a29f
+ * 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");
+ }
@ -38,7 +56,7 @@ index 028805bcdb1d2bb0d11387db165b7376579e5f60..51bc04571f75a4ccf05c3d080531a29f
// Paper start - oh my goddddd
/**
* Don't use this.
@@ -1238,6 +1252,11 @@ public final class PluginDescriptionFile implements io.papermc.paper.plugin.conf
@@ -1238,6 +1253,11 @@ public final class PluginDescriptionFile implements io.papermc.paper.plugin.conf
if (map.get("prefix") != null) {
prefix = map.get("prefix").toString();
}
@ -50,7 +68,7 @@ index 028805bcdb1d2bb0d11387db165b7376579e5f60..51bc04571f75a4ccf05c3d080531a29f
}
@NotNull
@@ -1314,6 +1333,11 @@ public final class PluginDescriptionFile implements io.papermc.paper.plugin.conf
@@ -1314,6 +1334,11 @@ public final class PluginDescriptionFile implements io.papermc.paper.plugin.conf
if (prefix != null) {
map.put("prefix", prefix);
}
@ -62,20 +80,3 @@ index 028805bcdb1d2bb0d11387db165b7376579e5f60..51bc04571f75a4ccf05c3d080531a29f
return map;
}
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
index 800f954161886ca4f6332f8e0cbc4d4e8f9cbb74..e0026c938aa369d6d9797852324437456d3c4ed9 100644
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
@@ -173,6 +173,12 @@ public final class SimplePluginManager implements PluginManager {
server.getLogger().log(Level.SEVERE, "Could not load '" + file.getPath() + "' in folder '" + directory.getPath() + "': uses the space-character (0x20) in its name");
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 '" + directory.getPath() + "'", ex);
continue;

View File

@ -0,0 +1,64 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Date: Wed, 29 Mar 2023 16:50:14 -0400
Subject: [PATCH] Require plugins to be explicitly marked as Folia supported
diff --git a/src/main/java/io/papermc/paper/plugin/provider/configuration/PaperPluginMeta.java b/src/main/java/io/papermc/paper/plugin/provider/configuration/PaperPluginMeta.java
index 3808f5a9abc9f084cbabfc4cb95394cc37aaf4bb..19a136c482ba28a2fcedc8e9c889510c974b8f68 100644
--- a/src/main/java/io/papermc/paper/plugin/provider/configuration/PaperPluginMeta.java
+++ b/src/main/java/io/papermc/paper/plugin/provider/configuration/PaperPluginMeta.java
@@ -62,6 +62,7 @@ public class PaperPluginMeta implements PluginMeta {
@Required
@PluginConfigConstraints.PluginVersion
private String apiVersion;
+ private boolean foliaSupported = false; // Folia
private transient String displayName;
@@ -204,6 +205,13 @@ public class PaperPluginMeta implements PluginMeta {
return this.apiVersion;
}
+ // Folia start
+ @Override
+ public boolean isFoliaSupported() {
+ return this.foliaSupported;
+ }
+ // Folia end
+
@Override
public @NotNull List<String> getProvidedPlugins() {
return this.provides;
diff --git a/src/main/java/io/papermc/paper/plugin/provider/type/paper/PaperPluginProviderFactory.java b/src/main/java/io/papermc/paper/plugin/provider/type/paper/PaperPluginProviderFactory.java
index eb0464a52d99a916bca8f93cd9294cdc30893671..923019a5823033871ab61ed9ed7625a2bc4d2b3d 100644
--- a/src/main/java/io/papermc/paper/plugin/provider/type/paper/PaperPluginProviderFactory.java
+++ b/src/main/java/io/papermc/paper/plugin/provider/type/paper/PaperPluginProviderFactory.java
@@ -24,6 +24,11 @@ class PaperPluginProviderFactory implements PluginTypeFactory<PaperPluginParent,
@Override
public PaperPluginParent build(JarFile file, PaperPluginMeta configuration, Path source) throws Exception {
+ // Folia start - block plugins not marked as supported
+ if (!configuration.isFoliaSupported()) {
+ throw new RuntimeException("Could not load plugin '" + configuration.getDisplayName() + "' as it is not marked as supporting Folia!");
+ }
+ // Folia end - block plugins not marked as supported
Logger jul = PaperPluginLogger.getLogger(configuration);
ComponentLogger logger = ComponentLogger.logger(jul.getName());
PluginProviderContext context = PluginProviderContextImpl.of(configuration, logger);
diff --git a/src/main/java/io/papermc/paper/plugin/provider/type/spigot/SpigotPluginProviderFactory.java b/src/main/java/io/papermc/paper/plugin/provider/type/spigot/SpigotPluginProviderFactory.java
index 14ed05945ba5bfeb2b539d4786278b0e04130404..ad13d60eeb94a75c97b3d0696c39d834d6082bfa 100644
--- a/src/main/java/io/papermc/paper/plugin/provider/type/spigot/SpigotPluginProviderFactory.java
+++ b/src/main/java/io/papermc/paper/plugin/provider/type/spigot/SpigotPluginProviderFactory.java
@@ -17,6 +17,11 @@ class SpigotPluginProviderFactory implements PluginTypeFactory<SpigotPluginProvi
@Override
public SpigotPluginProvider build(JarFile file, PluginDescriptionFile configuration, Path source) throws Exception {
+ // Folia start - block plugins not marked as supported
+ if (!configuration.isFoliaSupported()) {
+ throw new RuntimeException("Could not load plugin '" + configuration.getDisplayName() + "' as it is not marked as supporting Folia!");
+ }
+ // Folia end - block plugins not marked as supported
// Copied from SimplePluginManager#loadPlugins
// Spigot doesn't validate the name when the config is created, and instead when the plugin is loaded.
// Paper plugin configuration will do these checks in config serializer instead of when this is created.