@@ -8,15 +8,9 @@ import com.lambda.util.FolderRegister.mods
88import org.reflections.Reflections
99import org.reflections.scanners.Scanners
1010import org.reflections.util.ConfigurationBuilder
11- import java.io.File
12- import java.lang.reflect.Method
13- import java.net.URI
14- import java.net.URL
15- import java.net.URLClassLoader
16- import java.util.jar.JarFile
1711
1812object PluginRegistry : Loadable {
19- val plugins = mutableListOf< Plugin >()
13+ val plugins = mutableMapOf< String , Plugin >()
2014
2115 private val loadingError = """
2216 An error occurred while loading a plugin.
@@ -40,17 +34,27 @@ object PluginRegistry : Loadable {
4034 val instance = (pluginClass.declaredFields.find { it.name == " INSTANCE" }?.get(null )
4135 ? : pluginClass.constructors.firstOrNull()?.newInstance()) as ? Plugin
4236 ? : null .also {
43- loadingError.format(
44- pluginClass,
45- " The plugin does not have an object instance or a public constructor"
46- ).also { LOG .warn(it) }
37+ LOG .warn(
38+ loadingError.format(
39+ pluginClass,
40+ " The plugin does not have an object instance or a public constructor"
41+ )
42+ )
4743 }
4844
49- plugins.add(instance ? : return @forEach)
45+ val plugin = instance ? : return @forEach
46+ plugins[plugin.name] = plugin
5047 }
5148
52- // TODO: Implement API logic here
49+ // plugins.forEach { (_, plugin) ->
50+ // node(plugin, plugin
51+ // .dependencies
52+ // ?.mapNotNull { name ->
53+ // plugins[name] ?: return@mapNotNull null.also {
54+ // LOG.error("Plugin ${plugin.name} has a dependency on $name, which does not exist")
55+ // }
56+ // } ?: emptyList())
5357
54- return " Registered ${plugins.size} plugins"
58+ return " Loaded ${plugins.size} plugins"
5559 }
5660}
0 commit comments