mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 19:52:55 +01:00
64 lines
3 KiB
Diff
64 lines
3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: jmp <jasonpenilla2@me.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 63639923f7875d76f569b8c6e958782c6462d906..f1e6d0050092ad51bf233c80b6a51a121e961b07 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -384,8 +384,13 @@ public final class CraftServer implements Server {
|
|
|
|
File pluginFolder = (File) console.options.valueOf("plugins");
|
|
|
|
- if (pluginFolder.exists()) {
|
|
- Plugin[] plugins = pluginManager.loadPlugins(pluginFolder);
|
|
+ // Paper start
|
|
+ if (true || pluginFolder.exists()) {
|
|
+ if (!pluginFolder.exists()) {
|
|
+ pluginFolder.mkdirs();
|
|
+ }
|
|
+ Plugin[] plugins = pluginManager.loadPlugins(pluginFolder, this.extraPluginJars());
|
|
+ // Paper end
|
|
for (Plugin plugin : plugins) {
|
|
try {
|
|
String message = String.format("Loading %s", plugin.getDescription().getFullName());
|
|
@@ -400,6 +405,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) {
|
|
helpMap.clear();
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
index bd10345cb90f98b8af1519afd603a5244f3a5ca2..521542999b25b1da448fadb3fe6531e083f93e67 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"))
|
|
+ .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
|
|
}
|
|
};
|