= Updated plugins to each have their own global context

This commit is contained in:
Matthew Cech
2019-04-20 23:02:43 -07:00
parent 30ed670218
commit 25d8d51b1d
6 changed files with 71 additions and 71 deletions
+7 -7
View File
@@ -9,7 +9,6 @@ import java.util.stream.Stream;
// Reads in, handles, and manipulates plugins. Plugins are loaded in the order they appear in the folder.
public class PluginManager
{
public PluginLoader pluginLoader;
public final String pluginFolder;
public ArrayList<Plugin> plugins;
@@ -22,8 +21,7 @@ public class PluginManager
{
this.pluginFolder = folder;
plugins = new ArrayList<Plugin>();
this.pluginLoader = new PluginLoader();
try
{
try (Stream<Path> paths = Files.walk(Paths.get(this.pluginFolder)))
@@ -37,16 +35,18 @@ public class PluginManager
}
}
public String CallAll(String input)
// Runs all plugins, returning when it gets a non-nill result.
// Otherwise, returns null.
public String RunAll(String input)
{
for(int i = 0; i < plugins.size(); ++i)
{
Plugin script = plugins.get(i);
String out = pluginLoader.Process(script, input);
Plugin plugin = plugins.get(i);
String out = plugin.Run(input);
if(out != null)
{
PluginLog.Log("Executed plugin at " + script.filepath);
PluginLog.Log("Executed plugin at " + plugin.filepath);
return out;
}
}