From 8b2bc18775d69d4ab854eed7e3e10e36085043fd Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Mon, 7 Aug 2023 23:11:13 +0200 Subject: code cleanup --- .../features/misc/ghostcounter/GhostCounter.kt | 46 +++++++++++++++------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt index 82f80a044..2cbab2a26 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt @@ -53,12 +53,17 @@ object GhostCounter { val config get() = SkyHanniMod.feature.ghostCounter val hidden get() = ProfileStorageData.profileSpecific?.ghostCounter private var display = emptyList>() - var ghostCounterV3File = File("." + File.separator + "config" + File.separator + "ChatTriggers" + File.separator + "modules" + File.separator + "GhostCounterV3" + File.separator + ".persistantData.json") + var ghostCounterV3File = + File("." + File.separator + "config" + File.separator + "ChatTriggers" + File.separator + "modules" + File.separator + "GhostCounterV3" + File.separator + ".persistantData.json") private val skillXPPattern = "[+](?[0-9,.]+) \\((?[0-9,.]+)(?:/(?[0-9,.]+))?\\)".toPattern() - private val combatSectionPattern = ".*[+](?[0-9,.]+) (?[A-Za-z]+) \\((?(?[0-9.,]+)/(?[0-9.,]+)|(?[0-9.]+)%)\\).*".toPattern() - private val killComboExpiredPattern = "§cYour Kill Combo has expired! You reached a (?.*) Kill Combo!".toPattern() - private val ghostXPPattern = "(?\\d+(?:\\.\\d+)?(?:,\\d+)?[kK]?)\\/(?\\d+(?:\\.\\d+)?(?:,\\d+)?[kKmM]?)".toPattern() - private val bestiaryPattern = ".*(?:§\\d|§\\w)+BESTIARY (?:§\\d|§\\w)+Ghost (?:§\\d|§\\w)(?\\d+)➜(?:§\\d|§\\w)(?\\d+).*".toPattern() // &3&lBESTIARY &b&lGhost &89➜&b10 + private val combatSectionPattern = + ".*[+](?[0-9,.]+) (?[A-Za-z]+) \\((?(?[0-9.,]+)/(?[0-9.,]+)|(?[0-9.]+)%)\\).*".toPattern() + private val killComboExpiredPattern = + "§cYour Kill Combo has expired! You reached a (?.*) Kill Combo!".toPattern() + private val ghostXPPattern = + "(?\\d+(?:\\.\\d+)?(?:,\\d+)?[kK]?)/(?\\d+(?:\\.\\d+)?(?:,\\d+)?[kKmM]?)".toPattern() + private val bestiaryPattern = + ".*(?:§\\d|§\\w)+BESTIARY (?:§\\d|§\\w)+Ghost (?:§\\d|§\\w)(?\\d+)➜(?:§\\d|§\\w)(?\\d+).*".toPattern() // &3&lBESTIARY &b&lGhost &89➜&b10 private val skillLevelPattern = ".*§e§lSkills: §r§a(?.*) (?\\d+).*".toPattern() private val format = NumberFormat.getInstance() private var percent: Float = 0.0f @@ -76,15 +81,17 @@ object GhostCounter { private var killETA = "" private var currentSkill = "" private var currentSkillLevel = -1 - private const val configUpdateVersion = 1 + private const val CONFIG_VALUE_VERSION = 1 @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { if (!isEnabled()) return if (config.onlyOnMist && !inMist) return - config.position.renderStringsAndItems(display, + config.position.renderStringsAndItems( + display, extraSpace = config.extraSpace, - posLabel = "Ghost Counter") + posLabel = "Ghost Counter" + ) } private fun formatDisplay(map: List>): List> { @@ -206,7 +213,10 @@ object GhostCounter { addAsSingletonList(textFormatting.killComboFormat.formatText(MAXKILLCOMBO)) addAsSingletonList(textFormatting.highestKillComboFormat.formatText(MAXKILLCOMBO)) addAsSingletonList(textFormatting.skillXPGainFormat.formatText(SKILLXPGAINED)) - addAsSingletonList(bestiaryFormatting.base.preFormat(bestiary, nextLevel - 1, nextLevel).formatBestiary(currentKill, killNeeded)) + addAsSingletonList( + bestiaryFormatting.base.preFormat(bestiary, nextLevel - 1, nextLevel) + .formatBestiary(currentKill, killNeeded) + ) addAsSingletonList(xpHourFormatting.base.formatText(xp)) addAsSingletonList(killHourFormatting.base.formatText(killHour)) @@ -272,10 +282,14 @@ object GhostCounter { if (notifyCTModule && ProfileStorageData.profileSpecific?.ghostCounter?.ctDataImported != true) { notifyCTModule = false if (isUsingCTGhostCounter()) { - clickableChat("§6[SkyHanni] GhostCounterV3 ChatTriggers module has been detected, do you want to import saved data ? Click here to import data", "shimportghostcounterdata") + clickableChat( + "§6[SkyHanni] GhostCounterV3 ChatTriggers module has been detected, do you want to import saved data ? Click here to import data", + "shimportghostcounterdata" + ) } } - inMist = Minecraft.getMinecraft().thePlayer.posY <= 110 // some area don't show as 'The Mist' in the scoreboard + // some area don't show as 'The Mist' in the scoreboard + inMist = Minecraft.getMinecraft().thePlayer.posY <= 110 update() } if (event.repeatSeconds(2)) { @@ -308,8 +322,9 @@ object GhostCounter { var parse = true if (skillPercent) { percent = nf.parse(group("percent")).toFloat() - val level = if (currentSkill == "Combat" && currentSkillLevel != -1) currentSkillLevel else XPInformation.getInstance().getSkillInfo(skillName)?.level - ?: 0 + val level = + if (currentSkill == "Combat" && currentSkillLevel != -1) currentSkillLevel else XPInformation.getInstance() + .getSkillInfo(skillName)?.level ?: 0 if (level > 0) { totalSkillXp = SkillExperience.getExpForNextLevel(level) currentSkillXp = totalSkillXp * percent / 100 @@ -433,7 +448,8 @@ object GhostCounter { if (inventoryName != "Bestiary ➜ Dwarven Mines") return val stacks = event.inventoryItems val ghostStack = stacks[10] ?: return - val bestiaryNextLevel = if (ghostStack.displayName == "§cGhost") 1 else ghostStack.displayName.substring(8).romanToDecimal() + 1 + val bestiaryNextLevel = + if (ghostStack.displayName == "§cGhost") 1 else ghostStack.displayName.substring(8).romanToDecimal() + 1 hidden?.bestiaryNextLevel = bestiaryNextLevel.toDouble() var kills = 0.0 for (line in ghostStack.getLore()) { @@ -454,7 +470,7 @@ object GhostCounter { if (hidden?.configUpdateVersion == 0) { config.textFormatting.bestiaryFormatting.base = " &6Bestiary %display%: &b%value%" chat("§e[SkyHanni] Your GhostCounter config has been automatically adjusted.") - hidden?.configUpdateVersion = configUpdateVersion + hidden?.configUpdateVersion = CONFIG_VALUE_VERSION } } -- cgit