Skip to content

Commit db6f814

Browse files
committed
todo graph
1 parent 9bacd61 commit db6f814

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

common/src/main/kotlin/com/lambda/plugin/PluginRegistry.kt

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,9 @@ import com.lambda.util.FolderRegister.mods
88
import org.reflections.Reflections
99
import org.reflections.scanners.Scanners
1010
import 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

1812
object 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

Comments
 (0)