Initialize every button in Snowy.kt
This commit is contained in:
parent
9122d5f007
commit
3d08c24c17
|
@ -80,7 +80,8 @@ subprojects {
|
|||
listOf(
|
||||
"$kotlinX:kotlinx-datetime:0.2.0",
|
||||
"com.typesafe:config:1.4.1",
|
||||
"io.github.config4k:config4k:0.4.2"
|
||||
"io.github.config4k:config4k:0.4.2",
|
||||
"org.reflections:reflections:0.9.12"
|
||||
).forEach { implementation(it); shadowC(it) { isTransitive = false } }
|
||||
"minecraft"("com.mojang:minecraft:${rootProject.property("minecraft")}")
|
||||
"mappings"(mappingsDep)
|
||||
|
@ -120,6 +121,7 @@ allprojects {
|
|||
withType(ShadowJar::class) {
|
||||
relocate("kotlinx-datetime", "${rootProject.group}.kotlinx-datetime")
|
||||
relocate("org.jetbrains", "${rootProject.group}.jetbrainslibs")
|
||||
relocate("org.reflections", "${rootProject.group}.reflectionlib")
|
||||
relocate("com.typesafe.config", "${rootProject.group}.typesafe.config")
|
||||
relocate("io.github.config4k", "${rootProject.group}.config4k")
|
||||
relocate("net.arikia.dev.drpc", "${rootProject.group}.drpc")
|
||||
|
|
|
@ -2,14 +2,17 @@ package fr.username404.snowygui
|
|||
|
||||
import fr.username404.snowygui.EventSnowy.Companion.useKey
|
||||
import fr.username404.snowygui.config.Configuration.obtained
|
||||
import fr.username404.snowygui.gui.feature.ButtonInfo
|
||||
import fr.username404.snowygui.misc.AddKeyMaps
|
||||
import io.github.config4k.getValue
|
||||
import org.apache.logging.log4j.LogManager
|
||||
import org.apache.logging.log4j.Logger
|
||||
import org.reflections.Reflections
|
||||
|
||||
abstract class Snowy {
|
||||
private val displayInitMessage: Boolean by obtained
|
||||
companion object {
|
||||
val reflections = Reflections("fr.username404.snowygui")
|
||||
fun onEvent(e: String, lambda: argsLambda) = useKey(e).add(lambda)
|
||||
@JvmField
|
||||
val logs: Logger = LogManager.getLogger()
|
||||
|
@ -25,6 +28,15 @@ abstract class Snowy {
|
|||
}
|
||||
fun atInit() {
|
||||
if (displayInitMessage) logs.info("Init point of SnowyGUI hit.")
|
||||
reflections.getTypesAnnotatedWith(ButtonInfo::class.java).forEach { // Initializes every button
|
||||
logs.info(
|
||||
try {
|
||||
it.getConstructor().newInstance()
|
||||
} catch (e: NoSuchMethodException) {
|
||||
it.kotlin.objectInstance
|
||||
}
|
||||
)
|
||||
}
|
||||
eventsInit()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue