mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 20:07:41 +01:00
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
This commit is contained in:
parent
d4d8262f6e
commit
e183355647
@ -83,6 +83,20 @@ public final class Bukkit {
|
|||||||
return server;
|
return server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the de facto plugins directory, generally used for storing plugin jars to be loaded,
|
||||||
|
* as well as their {@link org.bukkit.plugin.Plugin#getDataFolder() data folders}.
|
||||||
|
*
|
||||||
|
* <p>Plugins should use {@link org.bukkit.plugin.Plugin#getDataFolder()} rather than traversing this
|
||||||
|
* directory manually when determining the location in which to store their data and configuration files.</p>
|
||||||
|
*
|
||||||
|
* @return plugins directory
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public static File getPluginsFolder() {
|
||||||
|
return server.getPluginsFolder();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to set the {@link Server} singleton.
|
* Attempts to set the {@link Server} singleton.
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -68,6 +68,18 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
*/
|
*/
|
||||||
public interface Server extends PluginMessageRecipient, net.kyori.adventure.audience.ForwardingAudience { // Paper
|
public interface Server extends PluginMessageRecipient, net.kyori.adventure.audience.ForwardingAudience { // Paper
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the de facto plugins directory, generally used for storing plugin jars to be loaded,
|
||||||
|
* as well as their {@link org.bukkit.plugin.Plugin#getDataFolder() data folders}.
|
||||||
|
*
|
||||||
|
* <p>Plugins should use {@link org.bukkit.plugin.Plugin#getDataFolder()} rather than traversing this
|
||||||
|
* directory manually when determining the location in which to store their data and configuration files.</p>
|
||||||
|
*
|
||||||
|
* @return plugins directory
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
File getPluginsFolder();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for all administrative messages, such as an operator using a
|
* Used for all administrative messages, such as an operator using a
|
||||||
* command.
|
* command.
|
||||||
|
@ -117,9 +117,22 @@ public final class SimplePluginManager implements PluginManager {
|
|||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
public Plugin[] loadPlugins(@NotNull File directory) {
|
public Plugin[] loadPlugins(@NotNull File directory) {
|
||||||
|
// Paper start - extra jars
|
||||||
|
return this.loadPlugins(directory, java.util.Collections.emptyList());
|
||||||
|
}
|
||||||
|
@NotNull
|
||||||
|
public Plugin[] loadPlugins(final @NotNull File directory, final @NotNull List<File> extraPluginJars) {
|
||||||
|
// Paper end
|
||||||
if (true) {
|
if (true) {
|
||||||
List<Plugin> pluginList = new ArrayList<>();
|
List<Plugin> pluginList = new ArrayList<>();
|
||||||
java.util.Collections.addAll(pluginList, this.paperPluginManager.loadPlugins(directory));
|
java.util.Collections.addAll(pluginList, this.paperPluginManager.loadPlugins(directory));
|
||||||
|
for (File file : extraPluginJars) {
|
||||||
|
try {
|
||||||
|
pluginList.add(this.paperPluginManager.loadPlugin(file));
|
||||||
|
} catch (Exception e) {
|
||||||
|
this.server.getLogger().log(Level.SEVERE, "Plugin loading error!", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
return pluginList.toArray(new Plugin[0]);
|
return pluginList.toArray(new Plugin[0]);
|
||||||
}
|
}
|
||||||
Preconditions.checkArgument(directory != null, "Directory cannot be null");
|
Preconditions.checkArgument(directory != null, "Directory cannot be null");
|
||||||
|
@ -93,7 +93,7 @@ public final class JavaPluginLoader implements PluginLoader {
|
|||||||
throw new InvalidPluginException(ex);
|
throw new InvalidPluginException(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
final File parentFile = file.getParentFile();
|
final File parentFile = this.server.getPluginsFolder(); // Paper
|
||||||
final File dataFolder = new File(parentFile, description.getName());
|
final File dataFolder = new File(parentFile, description.getName());
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
final File oldDataFolder = new File(parentFile, description.getRawName());
|
final File oldDataFolder = new File(parentFile, description.getRawName());
|
||||||
|
Loading…
Reference in New Issue
Block a user