From d8dad8b5f6cc28b23d503a3fd70c5d36d107eea0 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 25 Dec 2023 01:02:13 +0100 Subject: Added debug command /shfindnullconfig --- .../skyhanni/test/SkyHanniDebugsAndTests.kt | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/main/java/at/hannibal2/skyhanni/test') diff --git a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt index ed87e6da7..1adf858c7 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.config.ConfigFileType import at.hannibal2.skyhanni.config.ConfigGuiManager import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.config.core.config.Position import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.SlayerAPI import at.hannibal2.skyhanni.events.GuiRenderEvent @@ -136,6 +137,48 @@ class SkyHanniDebugsAndTests { // } } + fun findNullConfig(args: Array) { + println("start null finder") + findNull(SkyHanniMod.feature, "config") + println("stop null finder") + } + + private fun findNull(obj: Any, path: String) { + + val blockedNames = listOf( + "TRUE", + "FALSE", + "SIZE", + "MIN_VALUE", + "MAX_VALUE", + "BYTES", + "POSITIVE_INFINITY", + "NEGATIVE_INFINITY", + "NaN", + "MIN_NORMAL", + ) + + val javaClass = obj.javaClass + if (javaClass.isEnum) return + for (field in javaClass.fields) { + val name = field.name + if (name in blockedNames) continue + + // funny thing + if (obj is Position) { + if (name == "internalName") continue + } + + val other = field.makeAccessible().get(obj) + val newName = "$path.$name" + if (other == null) { + println("config null at $newName") + } else { + findNull(other, newName) + } + } + } + fun configManagerResetCommand(args: Array) { if (args.size == 1 && args[0] == "confirm") { configManagerReset() -- cgit