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
parent 7fceedc84f
commit 81f79b407d

View File

@ -5592,9 +5592,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ plugin = bootstrap.createPlugin(PaperPluginParent.this.context); + 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()))) { + 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; + this.status = ProviderStatus.INITIALIZED;