From 4a8fb34da085d16c7b778f433521390fe518bab2 Mon Sep 17 00:00:00 2001 From: superhize Date: Wed, 2 Aug 2023 00:56:40 +0200 Subject: updated ebstiary data and fixed few things --- .../java/at/hannibal2/skyhanni/config/Storage.java | 3 ++ .../config/features/GhostCounterConfig.java | 5 +- .../features/misc/ghostcounter/GhostCounter.kt | 61 +++++++++++++--------- .../features/misc/ghostcounter/GhostData.kt | 57 +++++++------------- .../features/misc/ghostcounter/GhostUtil.kt | 22 +++++--- 5 files changed, 77 insertions(+), 71 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index 1236d4313..7da36ec1f 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -243,6 +243,9 @@ public class Storage { @Expose public double totalMF = 0; + @Expose + public int configUpdateVersion = 0; + } @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/GhostCounterConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/GhostCounterConfig.java index 4aed852c1..d69b6e833 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/GhostCounterConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/GhostCounterConfig.java @@ -172,7 +172,8 @@ public class GhostCounterConfig { "§e%nextLevel% §7is replaced with your current bestiary level +1.\n" + "§e%value% §7is replaced with one of the text below.") @ConfigEditorText - public String base = " &6Bestiary %currentLevel%->%nextLevel%: &b%value%"; + // public String base = " &6Bestiary %currentLevel%->%nextLevel%: &b%value%"; + public String base = " &6Bestiary %display%: &b%value%"; @Expose @ConfigOption(name = "No Data", desc = "Text to show when you need to open the\nBestiary Menu to gather data.") @@ -189,7 +190,7 @@ public class GhostCounterConfig { @ConfigOption(name = "Progress to Max", desc = "Text to show progress when the §eMaxed Bestiary §7option is §aON\n" + "§e%currentKill% §7is replaced with your current total kill.") @ConfigEditorText - public String showMax_progress = "%currentKill%/3M (%percentNumber%%)"; + public String showMax_progress = "%currentKill%/250k (%percentNumber%%)"; @Expose @ConfigOption(name = "Progress", desc = "Text to show progress when the §eMaxed Bestiary§7 option is §cOFF\n" + 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 c62f466c6..1f0cbfe30 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 @@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostData.bestiaryData import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostUtil.formatBestiary import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostUtil.formatText import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostUtil.isUsingCTGhostCounter +import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostUtil.preFormat import at.hannibal2.skyhanni.features.misc.ghostcounter.GhostUtil.prettyTime import at.hannibal2.skyhanni.utils.CombatUtils._isKilling import at.hannibal2.skyhanni.utils.CombatUtils.calculateETA @@ -26,6 +27,7 @@ import at.hannibal2.skyhanni.utils.CombatUtils.xpGainHourLast import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList +import at.hannibal2.skyhanni.utils.LorenzUtils.chat import at.hannibal2.skyhanni.utils.LorenzUtils.clickableChat import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber @@ -74,8 +76,15 @@ object GhostCounter { private var killETA = "" private var currentSkill = "" private var currentSkillLevel = -1 + private val configUpdateVersion = 1 - var bestiaryUpdate = false + 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 + } + } @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { @@ -132,32 +141,30 @@ object GhostCounter { val bestiaryFormatting = config.textFormatting.bestiaryFormatting val currentKill = hidden?.bestiaryCurrentKill?.toInt() ?: 0 val killNeeded = hidden?.bestiaryKillNeeded?.toInt() ?: 0 - val nextLevel = hidden?.bestiaryNextLevel?.toInt() ?: 0 + val nextLevel = hidden?.bestiaryNextLevel?.toInt() ?: -1 val bestiary = if (config.showMax) { when (nextLevel) { - -1 -> bestiaryFormatting.maxed - in 1..46 -> { + 26 -> bestiaryFormatting.maxed.replace("%currentKill%", currentKill.addSeparators()) + in 1..25 -> { val sum = bestiaryData.filterKeys { it <= nextLevel - 1 }.values.sum() + val cKill = sum + currentKill bestiaryCurrentKill = cKill bestiaryFormatting.showMax_progress } - else -> bestiaryFormatting.openMenu } } else { when (nextLevel) { - -1 -> bestiaryFormatting.maxed - in 1..46 -> bestiaryFormatting.progress + 26 -> bestiaryFormatting.maxed + in 1..25 -> bestiaryFormatting.progress else -> bestiaryFormatting.openMenu } } val etaFormatting = config.textFormatting.etaFormatting - //TODO: update - val max = if (bestiaryUpdate) 100_000 else 3_000_000 val remaining: Int = when (config.showMax) { - true -> max - bestiaryCurrentKill + true -> 250_000 - bestiaryCurrentKill false -> killNeeded - currentKill } @@ -206,7 +213,8 @@ 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.formatText(bestiary).formatBestiary(currentKill, killNeeded)) + addAsSingletonList(bestiaryFormatting.base.preFormat(bestiary,nextLevel-1, nextLevel).formatBestiary(currentKill, killNeeded)) + addAsSingletonList(xpHourFormatting.base.formatText(xp)) addAsSingletonList(killHourFormatting.base.formatText(killHour)) addAsSingletonList(etaFormatting.base.formatText(eta).formatText(killETA)) @@ -354,7 +362,7 @@ object GhostCounter { fun onChat(event: LorenzChatEvent) { if (!isEnabled()) return if (LorenzUtils.skyBlockIsland != IslandType.DWARVEN_MINES) return - for (opt in GhostData.Option.values()) { + for (opt in entries) { val pattern = opt.pattern ?: continue pattern.matchMatcher(event.message) { when (opt) { @@ -396,19 +404,17 @@ object GhostCounter { update() } //replace with BestiaryLevelUpEvent ? - bestiaryPattern.matchMatcher(event.message.removeColor()) { - val currentLevel = group("newLevel").toInt() - val max = if (bestiaryUpdate) 100_000.0 else 3_000_000.0 - val maxLevel = if (bestiaryUpdate) 26 else 47 - when (val nextLevel = if (currentLevel >= maxLevel - 1) maxLevel else currentLevel + 1) { - maxLevel -> { - hidden?.bestiaryNextLevel = -1.0 - hidden?.bestiaryCurrentKill = max + bestiaryPattern.matchMatcher(event.message) { + val currentLevel = group("nextLevel").toInt() + when (val nextLevel = if (currentLevel >= 25) 26 else currentLevel + 1) { + 26 -> { + hidden?.bestiaryNextLevel = 26.0 + hidden?.bestiaryCurrentKill = 250_000.0 hidden?.bestiaryKillNeeded = 0.0 } else -> { - val killNeeded: Int = bestiaryData[nextLevel] ?: 0 + val killNeeded: Int = bestiaryData[nextLevel] ?: -1 hidden?.bestiaryNextLevel = nextLevel.toDouble() hidden?.bestiaryCurrentKill = 0.0 hidden?.bestiaryKillNeeded = killNeeded.toDouble() @@ -431,16 +437,19 @@ object GhostCounter { fun onInventoryOpen(event: InventoryOpenEvent) { if (!LorenzUtils.inSkyBlock) return val inventoryName = event.inventoryName - val name = if (bestiaryUpdate) "Bestiary ➜ Dwarven Mines" else "Bestiary ➜ Deep Caverns" - if (inventoryName != name) return + if (inventoryName != "Bestiary ➜ Dwarven Mines") return val stacks = event.inventoryItems - val stack = if (bestiaryUpdate) 10 else 13 - val ghostStack = stacks[stack] ?: return + val ghostStack = stacks[10] ?: return 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()) { + val l = line.removeColor().trim() + if (l.startsWith("Kills: ")){ + kills = "Kills: (.*)".toRegex().find(l)?.groupValues?.get(1)?.formatNumber()?.toDouble() ?: 0.0 + } ghostXPPattern.matchMatcher(line.removeColor().trim()) { - hidden?.bestiaryCurrentKill = group("current").formatNumber().toDouble() + hidden?.bestiaryCurrentKill = if (kills>0) kills else group("current").formatNumber().toDouble() hidden?.bestiaryKillNeeded = group("total").formatNumber().toDouble() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostData.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostData.kt index 1ba330244..b67dea5d0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostData.kt @@ -20,46 +20,29 @@ object GhostData { ) val bestiaryData = mutableMapOf().apply { - - if (GhostCounter.bestiaryUpdate) { - val commonValue = 100_000 - for (i in 1..46) { + for (i in 1..25) { this[i] = when (i) { - 1 -> 10 - 2 -> 15 - 3 -> 75 - 4 -> 150 - 5 -> 250 - 6 -> 500 - 7 -> 1_500 - 8 -> 2_500 - 9 -> 5_000 - 10 -> 15_000 - 11 -> 25_000 - 12 -> 50_000 - else -> commonValue + 1 -> 5 + 2 -> 5 + 3 -> 5 + 4 -> 10 + 5 -> 25 + 6 -> 50 + 7 -> 100 + 8 -> 150 + 9 -> 150 + 10 -> 250 + 11 -> 750 + 12 -> 1_500 + 13 -> 2_000 + 14,15,16,17 -> 2_500 + 18 -> 3_000 + 19,20 -> 3_500 + 21 -> 25_000 + 22,23,24,25 -> 50_000 + else -> 0 } } - } else { - val commonValue = 100_000 - for (i in 1..46) { - this[i] = when (i) { - 1 -> 10 - 2 -> 15 - 3 -> 75 - 4 -> 150 - 5 -> 250 - 6 -> 500 - 7 -> 1_500 - 8 -> 2_500 - 9 -> 5_000 - 10 -> 15_000 - 11 -> 25_000 - 12 -> 50_000 - else -> commonValue - } - } - } } enum class Option(val pattern: Pattern? = null) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostUtil.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostUtil.kt index 2067af8f0..436cbcd53 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostUtil.kt @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.features.misc.ghostcounter +import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.utils.LorenzUtils @@ -12,7 +13,7 @@ import java.io.FileReader object GhostUtil { fun reset() { - for (opt in GhostData.Option.values()) { + for (opt in GhostData.Option.entries) { opt.set(0.0) opt.set(0.0, true) } @@ -85,6 +86,17 @@ object GhostUtil { .replace("&", "§")) } + fun String.preFormat(t: String, level: Int, nextLevel: Int): String { + return if (nextLevel == 26) { + val lol = Utils.chromaStringByColourCode(this.replace("%value%", t) + .replace("%display%", "25")) + lol + } else { + Utils.chromaStringByColourCode(this.replace("%value%", t) + .replace("%display%", "$level->${if (SkyHanniMod.feature.ghostCounter.showMax) "25" else nextLevel}")) + } + } + fun String.formatText(value: Double, session: Double): String { return Utils.chromaStringByColourCode(this.replace("%value%", value.roundToPrecision(2).addSeparators()) .replace("%session%", session.roundToPrecision(2).addSeparators()) @@ -92,11 +104,10 @@ object GhostUtil { } fun String.formatBestiary(currentKill: Int, killNeeded: Int): String { - val maxLevel = if (GhostCounter.bestiaryUpdate) "25" else "46" val bestiaryNextLevel = GhostCounter.hidden?.bestiaryNextLevel val currentLevel = - bestiaryNextLevel?.let { if (it.toInt() < 0) maxLevel else "${it.toInt() - 1}" } ?: "§cNo Bestiary Level Data!" - val nextLevel = bestiaryNextLevel?.let { if (GhostCounter.config.showMax) maxLevel else "${it.toInt()}" } + bestiaryNextLevel?.let { if (it.toInt() < 0) "25" else "${it.toInt() - 1}" } ?: "§cNo Bestiary Level Data!" + val nextLevel = bestiaryNextLevel?.let { if (GhostCounter.config.showMax) "25" else "${it.toInt()}" } ?: "§cNo Bestiary Level data!" return Utils.chromaStringByColourCode( @@ -110,7 +121,6 @@ object GhostUtil { } private fun percent(number: Double): String { - val max = if (GhostCounter.bestiaryUpdate) 3_000_000 else 100_000 - return "${((number / max) * 100).roundToPrecision(4)}" + return "${((number / 250_000) * 100).roundToPrecision(4)}" } } \ No newline at end of file -- cgit From 4e7cd6dd7c997f75778f3640248bf4a9057eb841 Mon Sep 17 00:00:00 2001 From: superhize Date: Sat, 5 Aug 2023 14:04:07 +0200 Subject: using ConfigLoadEvent instead of init{} --- .../features/misc/ghostcounter/GhostCounter.kt | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 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 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 } -- cgit