diff --git a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt index 1d81502f3f6..3b5915fee01 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/repo/RepoManager.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.data.repo import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigManager +import at.hannibal2.skyhanni.config.features.dev.RepositoryConfig import at.hannibal2.skyhanni.events.NeuRepositoryReloadEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.test.command.ErrorManager @@ -59,6 +60,12 @@ class RepoManager(private val configLocation: File) { fun getRepoLocation(): String { return "${config.location.user}/${config.location.name}/${config.location.branch}" } + + private val defaultUser = "hannibal002" + private val defaultName = "SkyHanni-REPO" + private val defaultBranch = "main" + + fun RepositoryConfig.RepositoryLocation.hasDefaultSettings() = user == defaultUser && name == defaultName && branch == defaultBranch } fun loadRepoInformation() { @@ -317,12 +324,9 @@ class RepoManager(private val configLocation: File) { } fun resetRepositoryLocation(manual: Boolean = false) { - val defaultUser = "hannibal002" - val defaultName = "SkyHanni-Repo" - val defaultBranch = "main" with(config.location) { - if (user == defaultUser && name == defaultName && branch == defaultBranch) { + if (hasDefaultSettings()) { if (manual) { ChatUtils.chat("Repo settings are already on default!") } @@ -346,7 +350,7 @@ class RepoManager(private val configLocation: File) { } private fun checkRepoLocation() { - if (config.location.user.isEmpty() || config.location.name.isEmpty() || config.location.branch.isEmpty()) { + if (config.location.run { user.isEmpty() || name.isEmpty() || branch.isEmpty() }) { ChatUtils.userError("Invalid Repo settings detected, resetting default settings.") resetRepositoryLocation() } diff --git a/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt index f464a66ce19..d75b5abc6a5 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/DebugCommand.kt @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.HypixelData import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.repo.RepoManager +import at.hannibal2.skyhanni.data.repo.RepoManager.Companion.hasDefaultSettings import at.hannibal2.skyhanni.events.DebugDataCollectEvent import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.LorenzUtils @@ -145,10 +146,18 @@ object DebugCommand { private fun repoData(event: DebugDataCollectEvent) { event.title("Repo Information") - event.addIrrelevant { - add(" repoAutoUpdate: ${SkyHanniMod.feature.dev.repo.repoAutoUpdate}") + val config = SkyHanniMod.feature.dev.repo + + val hasDefaultSettings = config.location.hasDefaultSettings() + val list = buildList { + add(" repoAutoUpdate: ${config.repoAutoUpdate}") add(" usingBackupRepo: ${RepoManager.usingBackupRepo}") - add(" repoLocation: '${RepoManager.getRepoLocation()}'") + if (hasDefaultSettings) { + add((" repo location: default")) + } else { + add(" non-default repo location: '${RepoManager.getRepoLocation()}'") + } + if (RepoManager.unsuccessfulConstants.isNotEmpty()) { add(" unsuccessful constants:") for (constant in RepoManager.unsuccessfulConstants) { @@ -156,6 +165,13 @@ object DebugCommand { } } } + + val isRelevant = RepoManager.usingBackupRepo || RepoManager.unsuccessfulConstants.isNotEmpty() || !hasDefaultSettings + if (isRelevant) { + event.addData(list) + } else { + event.addIrrelevant(list) + } } private fun player(event: DebugDataCollectEvent) {