diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-25 01:02:13 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-25 01:02:13 +0100 |
commit | d8dad8b5f6cc28b23d503a3fd70c5d36d107eea0 (patch) | |
tree | 809f22ca200d79c81a2edfe5e043ff84835840fd /src/main | |
parent | 8cdd576927e6731cb07efc9054dee1ddf72d86b5 (diff) | |
download | skyhanni-d8dad8b5f6cc28b23d503a3fd70c5d36d107eea0.tar.gz skyhanni-d8dad8b5f6cc28b23d503a3fd70c5d36d107eea0.tar.bz2 skyhanni-d8dad8b5f6cc28b23d503a3fd70c5d36d107eea0.zip |
Added debug command /shfindnullconfig
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt | 4 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/test/SkyHanniDebugsAndTests.kt | 43 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index da54eb54e..a202aa1dd 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -303,6 +303,10 @@ object Commands { private fun developersCodingHelp() { registerCommand("shrepopatterns", "See where regexes are loaded from") { RepoPatternGui.open() } registerCommand("shtest", "Unused test command.") { SkyHanniDebugsAndTests.testCommand(it) } + registerCommand( + "shfindnullconfig", + "Find config elements that are null and prints them into the console" + ) { SkyHanniDebugsAndTests.findNullConfig(it) } registerCommand("shdebugwaypoint", "Mark a waypoint on that location") { SkyHanniDebugsAndTests.waypoint(it) } registerCommand("shdebugtablist", "Set your clipboard as a fake tab list.") { TabListData.toggleDebugCommand() } registerCommand("shreloadlocalrepo", "Reloading the local repo data") { SkyHanniMod.repo.reloadLocalRepo() } 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<String>) { + 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<String>) { if (args.size == 1 && args[0] == "confirm") { configManagerReset() |