Paper/patches/server/0682-Add-command-line-option-to-load-extra-plugin-jars-no.patch
Nassim Jahnke 06db5d08b0
Updated Upstream (Bukkit/CraftBukkit) (#6589)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
44cfe143 SPIGOT-6249: Add Missing Effect Constants

CraftBukkit Changes:
14928261 SPIGOT-6249: Add Missing Effect Constants
332335e1 SPIGOT-6731: "Nag author" message in CraftServer lists one author only
6cd975d0 SPIGOT-5732, SPIGOT-6387: Overhaul Hanging entities
2021-09-11 19:27:48 +02:00

65 lines
3.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Date: Tue, 18 May 2021 14:39:44 -0700
Subject: [PATCH] Add command line option to load extra plugin jars not in the
plugins folder
ex: java -jar paperclip.jar nogui -add-plugin=/path/to/plugin.jar -add-plugin=/path/to/another/plugin_jar.jar
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index b833a9eb958eeccc642869d669b3a63583d0fffa..4d330d1f71448cb9cbeb14cff04b48fdf18d3298 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -400,8 +400,13 @@ public final class CraftServer implements Server {
File pluginFolder = (File) console.options.valueOf("plugins");
- if (pluginFolder.exists()) {
- Plugin[] plugins = this.pluginManager.loadPlugins(pluginFolder);
+ // Paper start
+ if (true || pluginFolder.exists()) {
+ if (!pluginFolder.exists()) {
+ pluginFolder.mkdirs();
+ }
+ Plugin[] plugins = this.pluginManager.loadPlugins(pluginFolder, this.extraPluginJars());
+ // Paper end
for (Plugin plugin : plugins) {
try {
String message = String.format("Loading %s", plugin.getDescription().getFullName());
@@ -416,6 +421,18 @@ public final class CraftServer implements Server {
}
}
+ // Paper start
+ private List<File> extraPluginJars() {
+ @SuppressWarnings("unchecked")
+ final List<File> jars = (List<File>) this.console.options.valuesOf("add-plugin");
+ return jars.stream()
+ .filter(File::exists)
+ .filter(File::isFile)
+ .filter(file -> file.getName().endsWith(".jar"))
+ .collect(java.util.stream.Collectors.toList());
+ }
+ // Paper end
+
public void enablePlugins(PluginLoadOrder type) {
if (type == PluginLoadOrder.STARTUP) {
this.helpMap.clear();
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index c687df04b3543df763a4d5225342357355fab7ec..22e9dd17f62103c5061435099ce96a3d70d54808 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -153,6 +153,12 @@ public class Main {
.ofType(String.class)
.defaultsTo("Unknown Server")
.describedAs("Name");
+
+ acceptsAll(asList("add-plugin", "add-extra-plugin-jar"), "Specify paths to extra plugin jars to be loaded in addition to those in the plugins folder. This argument can be specified multiple times, once for each extra plugin jar path.")
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File[] {})
+ .describedAs("Jar file");
// Paper end
}
};