Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin folder path can now be specified #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/main/java/net/canarymod/plugin/DefaultPluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public final class DefaultPluginManager implements PluginManager {
private final Map<String, PluginDescriptor> plugins; // This is keyed to set Plugin name
private final DependencyGraph dependencies;
private final PropertiesFile pluginPriorities;
private String pluginPath;

public DefaultPluginManager() {
plugins = new LinkedHashMap<String, PluginDescriptor>();
Expand Down Expand Up @@ -310,7 +311,7 @@ public PluginDescriptor getPluginDescriptor(String plugin) {
*/
@Override
public void scanForPlugins() {
File pluginDir = new File("plugins/");
File pluginDir = new File(pluginPath);
if (!pluginDir.exists()) {
log.warn("Failed to scan for plugins. 'plugins/' is not a directory. Creating...");
pluginDir.mkdir();
Expand Down Expand Up @@ -338,6 +339,22 @@ public void scanForPlugins() {
log.info("Found " + loadedDescriptors + " plugins; total: " + plugins.size());
}
}

/**
* {@inheritDoc}
*/
@Override
public void setPluginPath(String path) {
this.pluginPath = path;
}

/**
* {@inheritDoc}
*/
@Override
public String getPluginPath() {
return pluginPath;
}

private boolean loadPluginDescriptorAndInsertInGraph(File pluginFile) throws InvalidPluginException {
PluginDescriptor desc = new PluginDescriptor(pluginFile.getAbsolutePath());
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/net/canarymod/plugin/PluginManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,18 @@ public interface PluginManager {
* @return List of known plugin names
*/
Collection<String> getPluginNames();

/**
* Sets the directory where the plugins are read
*
* @param path The Plugin folder path
*/
void setPluginPath(String path);

/**
* Gets the directory where the plugins are read
*
* @return the Plugin folder path
*/
String getPluginPath();
}