File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed
common/src/main/kotlin/com/lambda Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -14,9 +14,17 @@ import org.reflections.util.ConfigurationBuilder
1414 */
1515object CommandRegistry : Configurable(LambdaConfig ), Loadable {
1616 override val name = " command"
17-
1817 val prefix by setting(" prefix" , ' ;' )
19- val commands = getInstances<LambdaCommand > { forPackages(" com.lambda.command.commands" ) }
18+
19+ private val extraPackages = mutableSetOf<String >()
20+ val commands = getInstances<LambdaCommand > { forPackages(" com.lambda.command.commands" , * extraPackages.toTypedArray()) }
21+
22+ /* *
23+ * Injects a package into the [CommandRegistry] for scanning.
24+ *
25+ * @param packageName The package to inject into the [CommandRegistry].
26+ */
27+ fun injectPath (packageName : String ) = extraPackages.add(packageName)
2028
2129 override fun load (): String {
2230 return " Registered ${commands.size} commands"
Original file line number Diff line number Diff line change @@ -10,11 +10,19 @@ import org.reflections.util.ConfigurationBuilder
1010 * The [ModuleRegistry] object is responsible for managing all [Module] instances in the system.
1111 */
1212object ModuleRegistry : Loadable {
13- val modules = getInstances<Module > { forPackages(" com.lambda.module.modules" ) }
13+ private val extraPackages = mutableSetOf<String >()
14+ val modules = getInstances<Module > { forPackages(" com.lambda.module.modules" , * extraPackages.toTypedArray()) }
1415
1516 val moduleNames: Set <String >
1617 get() = modules.map { it.name }.toSet()
1718
19+ /* *
20+ * Injects a package into the [ModuleRegistry] for scanning.
21+ *
22+ * @param packageName The package to inject into the [ModuleRegistry].
23+ */
24+ fun injectPath (packageName : String ) = extraPackages.add(packageName)
25+
1826 override fun load (): String {
1927 return " Registered ${modules.size} modules with ${modules.sumOf { it.settings.size }} settings"
2028 }
You can’t perform that action at this time.
0 commit comments