make modules more dynamic

This commit is contained in:
Bixilon 2022-11-26 20:46:18 +01:00
parent 11891096fd
commit a99fc83b9e
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -21,10 +21,13 @@ import java.util.*
import java.util.zip.GZIPOutputStream import java.util.zip.GZIPOutputStream
object PixLyzer { object PixLyzer {
private val startTime = System.currentTimeMillis() private val START_TIME = System.currentTimeMillis()
val ENTITY_DATA_MAPPING = Util.readJsonResource("entities_data_mappings.json") val ENTITY_DATA_MAPPING = Util.readJsonResource("entities_data_mappings.json")
val TAG_CLASS = getClass("net.minecraft.tag.Tag", "com.mojang.datafixers.types.templates.Tag") val TAG_CLASS = getClass("net.minecraft.tag.Tag", "com.mojang.datafixers.types.templates.Tag")
val MODULES = listOf(
"de.bixilon.pixlyzer.physics.PhysicsExtractor",
)
lateinit var outputDirectory: File lateinit var outputDirectory: File
@ -92,12 +95,14 @@ object PixLyzer {
println("Class loading done in ${System.currentTimeMillis() - classesLoadStartTime}ms") println("Class loading done in ${System.currentTimeMillis() - classesLoadStartTime}ms")
val physics = getClass("de.bixilon.pixlyzer.physics.PhysicsExtractor") for (module in MODULES) {
if (physics == null) { val clazz = getClass(module)
println("Physics module not found, ignoring") if (clazz == null) {
} else { println("Can not find module: $module")
physics.forceInit() continue
physics.getDeclaredMethod("start").invoke(null) }
clazz.forceInit()
clazz.getDeclaredMethod("start").invoke(null)
} }
val all: MutableMap<String, Any> = mutableMapOf() val all: MutableMap<String, Any> = mutableMapOf()
@ -173,7 +178,7 @@ object PixLyzer {
println("Can not find mbf index file! Not indexing it.") println("Can not find mbf index file! Not indexing it.")
} }
println("Done in ${System.currentTimeMillis() - startTime}ms") println("Done in ${System.currentTimeMillis() - START_TIME}ms")
} }
fun Any.toJsonString(): String { fun Any.toJsonString(): String {