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;

View file

@ -5,10 +5,10 @@ Subject: [PATCH] Update the flag when a captured block state is outdated
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 3cbf801b2e5420c0e870f73788deb550e49ad54d..0454a9cfb60f17abba516cc2480ef31a95fada90 100644
index 2ecd29a24545418a2f6e2b2091d848313baabe91..db971ca4136c7f922d630f38aa5c78cb04adbdfa 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -525,6 +525,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
@@ -526,6 +526,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
blockstate = CapturedBlockState.getTreeBlockState(this, pos, flags);
this.capturedBlockStates.put(pos.immutable(), blockstate);
}