diff options
author | superhize <superhize@gmail.com> | 2023-08-05 14:04:07 +0200 |
---|---|---|
committer | superhize <superhize@gmail.com> | 2023-08-05 14:04:07 +0200 |
commit | 4e7cd6dd7c997f75778f3640248bf4a9057eb841 (patch) | |
tree | 06cabfc45373aab4094fe22065dea0401f5c3474 | |
parent | 4a8fb34da085d16c7b778f433521390fe518bab2 (diff) | |
download | skyhanni-4e7cd6dd7c997f75778f3640248bf4a9057eb841.tar.gz skyhanni-4e7cd6dd7c997f75778f3640248bf4a9057eb841.tar.bz2 skyhanni-4e7cd6dd7c997f75778f3640248bf4a9057eb841.zip |
using ConfigLoadEvent instead of init{}
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt | 26 |
1 files changed, 14 insertions, 12 deletions
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 1f0cbfe30..e3bfb8cfc 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 @@ -76,15 +76,7 @@ object GhostCounter { private var killETA = "" private var currentSkill = "" private var currentSkillLevel = -1 - private val configUpdateVersion = 1 - - init { - 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 - } - } + private const val configUpdateVersion = 1 @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { @@ -152,6 +144,7 @@ object GhostCounter { bestiaryCurrentKill = cKill bestiaryFormatting.showMax_progress } + else -> bestiaryFormatting.openMenu } } else { @@ -213,7 +206,7 @@ object GhostCounter { addAsSingletonList(config.textFormatting.killComboFormat.formatText(KILLCOMBO.getInt(), MAXKILLCOMBO.getInt(true))) addAsSingletonList(config.textFormatting.highestKillComboFormat.formatText(MAXKILLCOMBO.getInt(), MAXKILLCOMBO.getInt(true))) addAsSingletonList(config.textFormatting.skillXPGainFormat.formatText(SKILLXPGAINED.get(), SKILLXPGAINED.get(true))) - 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)) @@ -445,17 +438,26 @@ object GhostCounter { var kills = 0.0 for (line in ghostStack.getLore()) { val l = line.removeColor().trim() - if (l.startsWith("Kills: ")){ + if (l.startsWith("Kills: ")) { kills = "Kills: (.*)".toRegex().find(l)?.groupValues?.get(1)?.formatNumber()?.toDouble() ?: 0.0 } ghostXPPattern.matchMatcher(line.removeColor().trim()) { - hidden?.bestiaryCurrentKill = if (kills>0) kills else group("current").formatNumber().toDouble() + hidden?.bestiaryCurrentKill = if (kills > 0) kills else group("current").formatNumber().toDouble() hidden?.bestiaryKillNeeded = group("total").formatNumber().toDouble() } } update() } + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + 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 + } + } + fun isEnabled(): Boolean { return LorenzUtils.inSkyBlock && config.enabled && LorenzUtils.skyBlockIsland == IslandType.DWARVEN_MINES } |