2021-06-11 12:02:28 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2021-06-17 09:37:24 +00:00
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
2021-06-11 12:02:28 +00:00
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
2021-06-21 08:41:00 +00:00
index 0811c2804820b1dc0c49a354216b8d4eabc451c0..0e11c5f2e11a0d75740c8810421bd935691f47b5 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2021-06-21 08:41:00 +00:00
@@ -385,8 +385,13 @@ public final class CraftServer implements Server {
2021-06-11 12:02:28 +00:00
File pluginFolder = (File) console.options.valueOf("plugins");
- if (pluginFolder.exists()) {
2021-06-15 02:59:31 +00:00
- Plugin[] plugins = this.pluginManager.loadPlugins(pluginFolder);
2021-06-11 12:02:28 +00:00
+ // Paper start
+ if (true || pluginFolder.exists()) {
+ if (!pluginFolder.exists()) {
+ pluginFolder.mkdirs();
+ }
2021-06-15 02:59:31 +00:00
+ Plugin[] plugins = this.pluginManager.loadPlugins(pluginFolder, this.extraPluginJars());
2021-06-11 12:02:28 +00:00
+ // Paper end
for (Plugin plugin : plugins) {
try {
String message = String.format("Loading %s", plugin.getDescription().getFullName());
2021-06-21 08:41:00 +00:00
@@ -401,6 +406,18 @@ public final class CraftServer implements Server {
2021-06-11 12:02:28 +00:00
}
}
+ // 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) {
2021-06-15 02:59:31 +00:00
this.helpMap.clear();
2021-06-11 12:02:28 +00:00
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
2021-06-17 19:12:40 +00:00
index daa881823f9a0757211e4fece8ebd9225f8b41bb..32f82c60b680180b256edff127e5a6ded42fccf4 100644
2021-06-11 12:02:28 +00:00
--- 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"))
+ .withRequiredArg()
+ .ofType(File.class)
+ .defaultsTo(new File[] {})
+ .describedAs("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.");
// Paper end
}
};