
com.freya02.botcommands.api.core.EventTreeService.kt Maven / Gradle / Ivy
package com.freya02.botcommands.api.core
import com.freya02.botcommands.api.core.events.BEvent
import com.freya02.botcommands.api.core.service.annotations.BService
import io.github.classgraph.ClassGraph
import net.dv8tion.jda.api.events.Event
import java.util.*
import kotlin.reflect.KClass
@BService
internal class EventTreeService internal constructor() {
private val map: Map, List>> = ClassGraph()
.acceptPackages(Event::class.java.packageName, BEvent::class.java.packageName)
.disableRuntimeInvisibleAnnotations()
.disableModuleScanning()
.disableNestedJarScanning()
.enableClassInfo()
.scan().use { scanResult ->
scanResult.allStandardClasses.associate { info ->
info.loadClass().kotlin to Collections.unmodifiableList(info.subclasses.map { subclassInfo -> subclassInfo.loadClass().kotlin })
}
}
internal fun getSubclasses(kClass: KClass<*>): List> = map[kClass] ?: emptyList()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy