mirror of
https://github.com/BX-Team/DivineMC.git
synced 2025-12-19 14:59:25 +00:00
51 lines
3.1 KiB
Diff
51 lines
3.1 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: dan28000 <pirkldan28@gmail.com>
|
|
Date: Thu, 12 Jun 2025 10:08:25 +0200
|
|
Subject: [PATCH] Implement loading plugins from external folder
|
|
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/plugin/PluginInitializerManager.java b/src/main/java/io/papermc/paper/plugin/PluginInitializerManager.java
|
|
index 70413fddd23ca1165cb5090cce4fddcb1bbca93f..ae70b84e6473fa2ed94416bf4bef88492de3e5f8 100644
|
|
--- a/src/main/java/io/papermc/paper/plugin/PluginInitializerManager.java
|
|
+++ b/src/main/java/io/papermc/paper/plugin/PluginInitializerManager.java
|
|
@@ -112,6 +112,20 @@ public class PluginInitializerManager {
|
|
// Register the default plugin directory
|
|
io.papermc.paper.plugin.util.EntrypointUtil.registerProvidersFromSource(io.papermc.paper.plugin.provider.source.DirectoryProviderSource.INSTANCE, pluginSystem.pluginDirectoryPath());
|
|
|
|
+ // DivineMC start - Register the plugin directory from flags
|
|
+ @SuppressWarnings("unchecked")
|
|
+ java.util.List<Path> pluginList = ((java.util.List<File>) optionSet.valuesOf("add-plugin-dir")).stream()
|
|
+ .filter(java.util.Objects::nonNull)
|
|
+ .map(f -> f.listFiles(file -> file.getName().endsWith(".jar")))
|
|
+ .filter(java.util.Objects::nonNull)
|
|
+ .flatMap(java.util.Arrays::stream)
|
|
+ .filter(File::isFile)
|
|
+ .map(File::toPath)
|
|
+ .toList();
|
|
+
|
|
+ io.papermc.paper.plugin.util.EntrypointUtil.registerProvidersFromSource(io.papermc.paper.plugin.provider.source.PluginFlagProviderSource.INSTANCE, pluginList);
|
|
+ // DivineMC end - Register the plugin directory from flags
|
|
+
|
|
// Register plugins from the flag
|
|
@SuppressWarnings("unchecked")
|
|
java.util.List<Path> files = ((java.util.List<File>) optionSet.valuesOf("add-plugin")).stream().map(File::toPath).toList();
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
index 0838fcfaa950300f7a394295509be86cab824f99..d9bf383c9cb4fedcea84044f7db0da68b05fab76 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
|
@@ -180,6 +180,14 @@ public class Main {
|
|
.describedAs("Yml file");
|
|
// DivineMC end - Configuration
|
|
|
|
+ // DivineMC start - Implement loading plugins from external folder
|
|
+ acceptsAll(asList("add-plugin-dir", "add-extra-plugin-dir"), "Specify paths to directories containing 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 directory path.")
|
|
+ .withRequiredArg()
|
|
+ .ofType(File.class)
|
|
+ .defaultsTo(new File("extra"))
|
|
+ .describedAs("Directory");
|
|
+ // DivineMC end - Implement loading plugins from external folder
|
|
+
|
|
this.accepts("server-name", "Name of the server")
|
|
.withRequiredArg()
|
|
.ofType(String.class)
|