aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMicah Rao <[email protected]>2024-02-09 16:05:13 -0500
committerGitHub <[email protected]>2024-02-09 22:05:13 +0100
commit69b52b4d8edc242cffd61c68dadf7208b508ce4e (patch)
tree90626081b30428162c958d54f8e7e845f028b05a
parent9c04729de1727cdbcfb0d045ca0f883840eb994d (diff)
downloadPaper-69b52b4d8edc242cffd61c68dadf7208b508ce4e.tar.gz
Paper-69b52b4d8edc242cffd61c68dadf7208b508ce4e.zip
Check for server JARs in plugin directory (#10228)
-rw-r--r--patches/server/0013-Paper-Plugins.patch15
1 files changed, 12 insertions, 3 deletions
diff --git a/patches/server/0013-Paper-Plugins.patch b/patches/server/0013-Paper-Plugins.patch
index 9d5b2ad42e..db0f1755aa 100644
--- a/patches/server/0013-Paper-Plugins.patch
+++ b/patches/server/0013-Paper-Plugins.patch
@@ -3,6 +3,7 @@ From: Owen1212055 <[email protected]>
Date: Wed, 6 Jul 2022 23:00:31 -0400
Subject: [PATCH] Paper Plugins
+Co-authored-by: Micah Rao <[email protected]>
diff --git a/src/main/java/io/papermc/paper/command/PaperCommand.java b/src/main/java/io/papermc/paper/command/PaperCommand.java
index 8ccc59473bac983ced6b9e4a57e0ec4ebd2b0f32..6d06b772ffb9d47d6a717462a4b2b494544e80ae 100644
@@ -5551,10 +5552,10 @@ index 0000000000000000000000000000000000000000..f30fcf60b64150e381c7b813016aa9dd
+}
diff --git a/src/main/java/io/papermc/paper/plugin/provider/source/FileProviderSource.java b/src/main/java/io/papermc/paper/plugin/provider/source/FileProviderSource.java
new file mode 100644
-index 0000000000000000000000000000000000000000..d33762ce5977636320e324dde4aab37075865d8d
+index 0000000000000000000000000000000000000000..5b58df8df7efca0f67e3a14dd71051dfd7a26079
--- /dev/null
+++ b/src/main/java/io/papermc/paper/plugin/provider/source/FileProviderSource.java
-@@ -0,0 +1,163 @@
+@@ -0,0 +1,171 @@
+package io.papermc.paper.plugin.provider.source;
+
+import io.papermc.paper.plugin.PluginInitializerManager;
@@ -5617,7 +5618,15 @@ index 0000000000000000000000000000000000000000..d33762ce5977636320e324dde4aab370
+ JarFile file = new JarFile(context.toFile(), true, JarFile.OPEN_READ, JarFile.runtimeVersion());
+ PluginFileType<?, ?> type = PluginFileType.guessType(file);
+ if (type == null) {
-+ throw new IllegalArgumentException(source + " does not contain a " + String.join(" or ", PluginFileType.getConfigTypes()) + "! Could not determine plugin type, cannot load a plugin from it!");
++ // Throw IAE wrapped in RE to prevent callers from considering this a "invalid parameter" as caller ignores IAE.
++ // TODO: This needs some heavy rework, using illegal argument exception to signal an actual failure is less than ideal.
++ if (file.getEntry("META-INF/versions.list") != null) {
++ throw new RuntimeException(new IllegalArgumentException(context + " appears to be a server jar! Server jars do not belong in the plugin folder."));
++ }
++
++ throw new RuntimeException(
++ new IllegalArgumentException(source + " does not contain a " + String.join(" or ", PluginFileType.getConfigTypes()) + "! Could not determine plugin type, cannot load a plugin from it!")
++ );
+ }
+
+ type.register(entrypointHandler, file, context);