= Updated plugin subsystem formatting
This commit is contained in:
@@ -12,14 +12,11 @@ import dataStructures.KittyUser;
|
||||
// Reads in, handles, and manipulates plugins. Plugins are loaded in the order they appear in the folder.
|
||||
public class PluginManager
|
||||
{
|
||||
// Variables
|
||||
public final String pluginFolder;
|
||||
public ArrayList<Plugin> plugins;
|
||||
|
||||
public void AddPlugin(Path path)
|
||||
{
|
||||
plugins.add(new Plugin(path));
|
||||
}
|
||||
|
||||
// Constructor
|
||||
public PluginManager(String folder)
|
||||
{
|
||||
this.pluginFolder = folder;
|
||||
@@ -29,30 +26,35 @@ public class PluginManager
|
||||
{
|
||||
try (Stream<Path> paths = Files.walk(Paths.get(this.pluginFolder)))
|
||||
{
|
||||
paths.filter(Files::isRegularFile).forEach((path)->{ AddPlugin(path); });
|
||||
paths.filter(Files::isRegularFile).forEach((path)->{ addPlugin(path); });
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
PluginLog.Error(e.getMessage());
|
||||
PluginLog.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlugin(Path path)
|
||||
{
|
||||
plugins.add(new Plugin(path));
|
||||
}
|
||||
|
||||
// Runs all plugins, returning when it gets a non-nill result. If there
|
||||
// are mutliple strings returned in the list, it is because the plugin
|
||||
// that was run returned multiple strings. Since plugins don't stack, it
|
||||
// will never indicate that multiple
|
||||
// Otherwise, returns null.
|
||||
public List<String> RunAll(String input, KittyUser user)
|
||||
public List<String> runAll(String input, KittyUser user)
|
||||
{
|
||||
for(int i = 0; i < plugins.size(); ++i)
|
||||
{
|
||||
Plugin plugin = plugins.get(i);
|
||||
List<String> out = plugin.Run(input, new PluginUser(user));
|
||||
List<String> out = plugin.run(input, new PluginUser(user));
|
||||
|
||||
if(out != null)
|
||||
{
|
||||
PluginLog.Log("Executed plugin at " + plugin.filepath);
|
||||
PluginLog.log("Executed plugin at " + plugin.filepath);
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -60,9 +62,10 @@ public class PluginManager
|
||||
return null;
|
||||
}
|
||||
|
||||
public void PrintAll()
|
||||
// Dumps the contents of all plugins for debug
|
||||
public void printAll()
|
||||
{
|
||||
for(int i = 0; i < plugins.size(); ++i)
|
||||
PluginLog.Log(plugins.get(i).contents.toString());
|
||||
PluginLog.log(plugins.get(i).contents.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user