Log message if plugin bootstrap provided external plugin instead of throwing an exception (#8914)

This commit is contained in:
Viktor Hrekh 2023-02-28 14:17:49 +02:00 committed by GitHub
parent dead691e8c
commit f408c253ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 5 deletions

View file

@ -5417,7 +5417,7 @@ new file mode 100644
index 0000000000000000000000000000000000000000..884ddb16ee6a5b182e932abb53fdf38a4444d765
--- /dev/null
+++ b/src/main/java/io/papermc/paper/plugin/provider/type/paper/PaperPluginParent.java
@@ -0,0 +1,258 @@
@@ -0,0 +1,257 @@
+package io.papermc.paper.plugin.provider.type.paper;
+
+import com.destroystokyo.paper.util.SneakyThrow;
@ -5592,9 +5592,8 @@ index 0000000000000000000000000000000000000000..884ddb16ee6a5b182e932abb53fdf38a
+ plugin = bootstrap.createPlugin(PaperPluginParent.this.context);
+ }
+
+ // Don't allow plugins to load plugins other than the one defined in main. This restriction might not be necessary.
+ if (!plugin.getClass().isAssignableFrom(Class.forName(PaperPluginParent.this.description.getMainClass(), true, plugin.getClass().getClassLoader()))) {
+ throw new IllegalArgumentException("Plugin provided must be the same type as main defined in plugin configuration!");
+ logger.info("Bootstrap of plugin " + PaperPluginParent.this.description.getName() + " provided a plugin instance of class " + plugin.getClass().getName() + " which does not match the plugin declared main class");
+ }
+
+ this.status = ProviderStatus.INITIALIZED;