mirror of
https://github.com/DanilaFe/abacus
synced 2024-12-22 23:40:08 -08:00
Load default plugin without jars.
This commit is contained in:
parent
ce9e32b08f
commit
0300bece46
|
@ -2,6 +2,7 @@ package org.nwapw.abacus;
|
|||
|
||||
import org.nwapw.abacus.plugin.PluginManager;
|
||||
//import org.nwapw.abacus.plugin.StandardPlugin;
|
||||
import org.nwapw.abacus.plugin.StandardPlugin;
|
||||
import org.nwapw.abacus.window.Window;
|
||||
import org.nwapw.abacus.plugin.ClassFinder;
|
||||
|
||||
|
@ -25,6 +26,7 @@ public class Abacus {
|
|||
e.printStackTrace();
|
||||
}
|
||||
manager = new PluginManager();
|
||||
manager.addInstantiated(new StandardPlugin(manager));
|
||||
try {
|
||||
ClassFinder.loadJars("plugins")
|
||||
.forEach(plugin -> manager.addClass(plugin));
|
||||
|
|
|
@ -12,10 +12,14 @@ import java.util.*;
|
|||
*/
|
||||
public class PluginManager {
|
||||
|
||||
/**
|
||||
* List of classes loaded by this manager.
|
||||
*/
|
||||
private Set<Class<?>> loadedPluginClasses;
|
||||
/**
|
||||
* A list of loaded plugins.
|
||||
*/
|
||||
private List<Plugin> plugins;
|
||||
private Set<Plugin> plugins;
|
||||
/**
|
||||
* List of functions that have been cached,
|
||||
* that is, found in a plugin and returned.
|
||||
|
@ -43,7 +47,8 @@ public class PluginManager {
|
|||
* Creates a new plugin manager.
|
||||
*/
|
||||
public PluginManager(){
|
||||
plugins = new ArrayList<>();
|
||||
loadedPluginClasses = new HashSet<>();
|
||||
plugins = new HashSet<>();
|
||||
cachedFunctions = new HashMap<>();
|
||||
cachedOperators = new HashMap<>();
|
||||
allFunctions = new HashSet<>();
|
||||
|
@ -104,7 +109,9 @@ public class PluginManager {
|
|||
* @param plugin the plugin to add.
|
||||
*/
|
||||
public void addInstantiated(Plugin plugin){
|
||||
if(loadedPluginClasses.contains(plugin.getClass())) return;
|
||||
plugins.add(plugin);
|
||||
loadedPluginClasses.add(plugin.getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user