From 52afdbf62ef5c35403132696918b9cfcc8faffdb Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal002@users.noreply.github.com> Date: Thu, 4 Apr 2024 20:32:01 +0200 Subject: Backend: error manager only for beta users (#1299) Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- .../features/gui/customscoreboard/ScoreboardElements.kt | 12 +++++++----- .../java/at/hannibal2/skyhanni/test/command/ErrorManager.kt | 9 +++++++-- src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 3 +++ 3 files changed, 17 insertions(+), 7 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt index 744b4fa45..d3e3b6c1c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/gui/customscoreboard/ScoreboardElements.kt @@ -807,16 +807,18 @@ private fun getFooterDisplayPair() = listOf( private fun getExtraDisplayPair(): List { if (unknownLines.isEmpty()) return listOf("" to HorizontalAlignment.LEFT) - if (amountOfUnknownLines != unknownLines.size && devConfig.unknownLinesWarning) { + val size = unknownLines.size + if (amountOfUnknownLines != size && devConfig.unknownLinesWarning) { + val message = "CustomScoreboard detected ${pluralize(unknownLines.size, "unknown line", withNumber = true)}" ErrorManager.logErrorWithData( - CustomScoreboardUtils.UndetectedScoreboardLines("CustomScoreboard detected ${pluralize(unknownLines.size, "unknown line", withNumber = true)}"), - "CustomScoreboard detected ${pluralize(unknownLines.size, "unknown line", withNumber = true)}", + CustomScoreboardUtils.UndetectedScoreboardLines(message), + message, "Unknown Lines" to unknownLines, "Island" to HypixelData.skyBlockIsland, "Area" to HypixelData.skyBlockArea, - noStackTrace = true + noStackTrace = true, ) - amountOfUnknownLines = unknownLines.size + amountOfUnknownLines = size } return listOf("§cUndetected Lines:" to HorizontalAlignment.LEFT) + unknownLines.map { it to HorizontalAlignment.LEFT } diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt index 5b369a35c..e29674fe9 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.test.command import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.KeyboardManager +import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.OSUtils import at.hannibal2.skyhanni.utils.StringUtils import at.hannibal2.skyhanni.utils.StringUtils.removeColor @@ -87,8 +88,9 @@ object ErrorManager { vararg extraData: Pair, ignoreErrorCache: Boolean = false, noStackTrace: Boolean = false, + betaOnly: Boolean = false, ) { - logError(IllegalStateException(internalMessage), userMessage, ignoreErrorCache, noStackTrace, *extraData) + logError(IllegalStateException(internalMessage), userMessage, ignoreErrorCache, noStackTrace, *extraData, betaOnly = betaOnly) } @Deprecated("Use data as well", ReplaceWith("ErrorManager.logErrorWithData(throwable, message)")) @@ -102,8 +104,9 @@ object ErrorManager { vararg extraData: Pair, ignoreErrorCache: Boolean = false, noStackTrace: Boolean = false, + betaOnly: Boolean = false, ) { - logError(throwable, message, ignoreErrorCache, noStackTrace, *extraData) + logError(throwable, message, ignoreErrorCache, noStackTrace, *extraData, betaOnly = betaOnly) } private fun logError( @@ -112,7 +115,9 @@ object ErrorManager { ignoreErrorCache: Boolean, noStackTrace: Boolean, vararg extraData: Pair, + betaOnly: Boolean = false, ) { + if (betaOnly && !LorenzUtils.isBetaVersion()) return if (!ignoreErrorCache) { val pair = if (throwable.stackTrace.isNotEmpty()) { throwable.stackTrace[0].let { (it.fileName ?: "") to it.lineNumber } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index 740c6acaf..9d65eca03 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.data.Perk import at.hannibal2.skyhanni.data.TitleManager import at.hannibal2.skyhanni.events.GuiContainerEvent import at.hannibal2.skyhanni.features.dungeon.DungeonAPI +import at.hannibal2.skyhanni.features.misc.update.UpdateManager import at.hannibal2.skyhanni.features.misc.visualwords.ModifyVisualWords import at.hannibal2.skyhanni.features.nether.kuudra.KuudraAPI import at.hannibal2.skyhanni.mixins.transformers.AccessorGuiEditSign @@ -395,4 +396,6 @@ object LorenzUtils { fun inMiningIsland() = IslandType.GOLD_MINES.isInIsland() || IslandType.DEEP_CAVERNS.isInIsland() || inAdvancedMiningIsland() + + fun isBetaVersion() = UpdateManager.isCurrentlyBeta() } -- cgit