From 7c3390cd700ab76e3044d98660ed4c23bcf6d4db Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Thu, 9 May 2024 09:06:04 +0200 Subject: [PATCH 01/27] start Signed-off-by: Empa <42304516+ItsEmpa@users.noreply.github.com> --- .../java/at/hannibal2/skyhanni/SkyHanniMod.kt | 2 + .../ghostcounter/GhostCounterConfig.java | 23 ++ .../storage/ProfileSpecificStorage.java | 13 + .../data/jsonobjects/repo/GhostDrops.java | 11 + .../combat/ghosttracker/GhostTracker.kt | 349 ++++++++++++++++++ 5 files changed, 398 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.java create mode 100644 src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 5caf505669c7..7e6cd5dfe42b 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -92,6 +92,7 @@ import at.hannibal2.skyhanni.features.combat.HideDamageSplash import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorManager import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostCounter +import at.hannibal2.skyhanni.features.combat.ghosttracker.GhostTracker import at.hannibal2.skyhanni.features.combat.mobs.AreaMiniBossFeatures import at.hannibal2.skyhanni.features.combat.mobs.AshfangMinisNametagHider import at.hannibal2.skyhanni.features.combat.mobs.MobHighlight @@ -923,6 +924,7 @@ class SkyHanniMod { loadModule(ColdOverlay()) loadModule(QuiverDisplay()) loadModule(QuiverWarning()) + loadModule(GhostTracker()) init() diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/GhostCounterConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/GhostCounterConfig.java index 613b1d120589..55243c128647 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/GhostCounterConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/GhostCounterConfig.java @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.config.core.config.Position; import at.hannibal2.skyhanni.config.features.combat.ghostcounter.textformatting.TextFormattingConfig; import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil; +import at.hannibal2.skyhanni.features.combat.ghosttracker.GhostTracker; import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.Accordion; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; @@ -36,6 +37,24 @@ public class GhostCounterConfig { @FeatureToggle public boolean enabled = true; + @Expose + @ConfigOption( + name = "Display Text", + desc = "Drag text to change the appearance of the overlay." + ) + @ConfigEditorDraggableList + public List ghostTrackerText = new ArrayList<>(Arrays.asList( + GhostTracker.GhostTrackerLines.TITLE, + GhostTracker.GhostTrackerLines.ITEMS, + GhostTracker.GhostTrackerLines.KILLS, + GhostTracker.GhostTrackerLines.GHOSTS_SINCE_SORROW, + GhostTracker.GhostTrackerLines.MAX_KILL_COMBO, + GhostTracker.GhostTrackerLines.COMBAT_XP_GAINED, + GhostTracker.GhostTrackerLines.AVERAGE_MAGIC_FIND, + GhostTracker.GhostTrackerLines.BESTIARY_KILLS, + GhostTracker.GhostTrackerLines.TOTAL_PROFIT + )); + @Expose @ConfigOption( name = "Display Text", @@ -140,4 +159,8 @@ public String toString() { @Expose @ConfigLink(owner = GhostCounterConfig.class, field = "enabled") public Position position = new Position(50, 50, false, true); + + @Expose + @ConfigLink(owner = GhostCounterConfig.class, field = "enabled") + public Position trackerPosition = new Position(50, 50, false, true); } diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java index 5487a35197de..d669cd8fca41 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java @@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.data.model.ComposterUpgrade; import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker; import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData; +import at.hannibal2.skyhanni.features.combat.ghosttracker.GhostTracker; import at.hannibal2.skyhanni.features.dungeon.CroesusChestTracker; import at.hannibal2.skyhanni.features.dungeon.DungeonFloor; import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker; @@ -399,6 +400,18 @@ public static class GhostCounter { } + @Expose + public GhostStorage ghostStorage = new GhostStorage(); + + public static class GhostStorage { + + @Expose + public GhostTracker.Data ghostTracker = new GhostTracker.Data(); + + @Expose + public Long bestiaryKills = 0L; + } + @Expose public PowderTracker.Data powderTracker = new PowderTracker.Data(); diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.java new file mode 100644 index 000000000000..79059335a5cf --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.java @@ -0,0 +1,11 @@ +package at.hannibal2.skyhanni.data.jsonobjects.repo; + +import at.hannibal2.skyhanni.utils.NEUInternalName; +import com.google.gson.annotations.Expose; + +import java.util.List; + +public class GhostDrops { + @Expose + public List ghost_drops; +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt new file mode 100644 index 000000000000..3a30d5510683 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -0,0 +1,349 @@ +package at.hannibal2.skyhanni.features.combat.ghosttracker + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.IslandType +import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.IslandChangeEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.events.PurseChangeCause +import at.hannibal2.skyhanni.events.PurseChangeEvent +import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.events.TabListUpdateEvent +import at.hannibal2.skyhanni.features.skillprogress.SkillType +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland +import at.hannibal2.skyhanni.utils.NEUInternalName +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import at.hannibal2.skyhanni.utils.NumberUtil +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.formatInt +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.StringUtils.matches +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import at.hannibal2.skyhanni.utils.tracker.ItemTrackerData +import at.hannibal2.skyhanni.utils.tracker.SkyHanniItemTracker +import com.google.gson.annotations.Expose +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +class GhostTracker { + + val config get() = SkyHanniMod.feature.combat.ghostCounter + + val storage = ProfileStorageData.profileSpecific?.ghostStorage + + var currentCombatXp = 0L + + var currentBestiaryKills = 0L + var lastBestiaryUpdate = SimpleTimeMark.farPast() + var isMaxBestiary = false + + private var allowedDrops = listOf() + + private val MAX_BESTIARY_KILLS = getBestiaryKillsUntilLevel(25) + + fun getCurrentCombatXp(): Long? = ProfileStorageData.profileSpecific?.skillData?.get(SkillType.COMBAT)?.totalXp + + private val tracker = SkyHanniItemTracker( + "Ghost Tracker", + { Data() }, + { it.ghostStorage.ghostTracker }) { drawDisplay(it) } + + class Data : ItemTrackerData() { + + override fun resetItems() { + kills = 0 + ghostsSinceSorrow = 0 + maxKillCombo = 0 + combatXpGained = 0 + } + + @Expose + var kills = 0L + + @Expose + var ghostsSinceSorrow = 0L + + @Expose + var maxKillCombo = 0L + + @Expose + var combatXpGained = 0L + + @Expose + var totalMagicFind = 0L + + @Expose + var totalMagicFindKills = 0L + + override fun getDescription(timesGained: Long): List { + val percentage = timesGained.toDouble() / kills + val perKill = LorenzUtils.formatPercentage(percentage.coerceAtMost(1.0)) + + return listOf( + "§7Dropped §e${timesGained.addSeparators()} §7times.", + "§7Your drop chance per kill: §c$perKill" + ) + } + + override fun getCoinName(item: TrackedItem) = "§6Dropped Coins" + + override fun getCoinDescription(item: TrackedItem): List { + val coinsFormat = NumberUtil.format(item.totalAmount) + return listOf( + "§7Killing ghosts gives you coins (more with scavenger).", + "§7You got §6$coinsFormat coins §7that way." + ) + } + } + + private val patternGroup = RepoPattern.group("combat.ghosttracker") + + private val itemDropPattern by patternGroup.pattern( + "itemdrop", + "§6§lRARE DROP! §r§9(?[^§]*) §r§b\\([+](?:§.)*(?\\d*)% §r§b✯ Magic Find§r§b\\)" + ) + private val killComboEndPattern by patternGroup.pattern( + "killcombo.end", + "§cYour Kill Combo has expired! You reached a (?\\d+) Kill Combo!" + ) + private val bagOfCashPattern by patternGroup.pattern( + "bagofcash", + "§eThe ghost's death materialized §r§61,000,000 coins §r§efrom the mists!" + ) + + /** + * REGEX-TEST: Ghost 15§r§f: §r§b12,449/12,500 + */ + private val bestiaryTablistPattern by patternGroup.pattern( + "tablist.bestiary", + "\\s*Ghost (?\\d+|[XVI]+)(?:§.)*: (?:§.)*(?[\\d,.]+)/(?[\\d,.]+)" + ) + private val maxBestiaryTablistPattern by patternGroup.pattern( + "tablist.bestiarymax", + "\\s*Ghost (?\\d+|[XVI]+)(?:§.)*: (?:§.)*MAX" + ) + + + private val SORROW by lazy { "SORROW".asInternalName() } + + private fun drawDisplay(data: Data): List> = buildList { + config.ghostTrackerText.forEach { line -> + val lines = getLine(line, data) + lines.forEach { add(it) } + } + } + + private fun getLine(line: GhostTrackerLines, data: Data): List> { + val itemsList = mutableListOf>() + val profit = tracker.drawItems(data, { true }, itemsList) + return when (line) { + GhostTrackerLines.TITLE -> listOf(listOf("§e§lGhost Profit Tracker")) + GhostTrackerLines.ITEMS -> itemsList + GhostTrackerLines.KILLS -> listOf(listOf("§7Kills: §e${data.kills.addSeparators()}")) + GhostTrackerLines.GHOSTS_SINCE_SORROW -> listOf(listOf("§7Ghosts Since Sorrow: §e${data.ghostsSinceSorrow.addSeparators()}")) + GhostTrackerLines.MAX_KILL_COMBO -> listOf(listOf("§7Max Kill Combo: §e${data.maxKillCombo.addSeparators()}")) + GhostTrackerLines.COMBAT_XP_GAINED -> listOf(listOf("§7Combat XP Gained: §e${data.combatXpGained.addSeparators()}")) + GhostTrackerLines.AVERAGE_MAGIC_FIND -> listOf( + listOf( + "§7Average Magic Find: §e${ + getAverageMagicFind( + data.totalMagicFind, + data.totalMagicFindKills + ) + }" + ) + ) + + GhostTrackerLines.BESTIARY_KILLS -> listOf(listOf("§7Bestiary Kills: §e" + if (currentBestiaryKills >= MAX_BESTIARY_KILLS) "MAX" else currentBestiaryKills.addSeparators())) + GhostTrackerLines.TOTAL_PROFIT -> listOf(listOf("§7Total Profit: §6${profit.addSeparators()} coins")) + } + } + + @SubscribeEvent + fun onProfileJoin(event: ProfileJoinEvent) { + currentCombatXp = getCurrentCombatXp() ?: 0L + currentBestiaryKills = storage?.bestiaryKills ?: 0 + isMaxBestiary = currentBestiaryKills >= 125_000 // TODO: actually get the max bestiary kills for ghosts + } + + // TODO: Skill xp gain event + @SubscribeEvent + fun onSecondPassed(event: SecondPassedEvent) { + if (!isEnabled()) return + val newXp = getCurrentCombatXp() ?: return + if (newXp <= currentCombatXp) return + + val difference = newXp - currentCombatXp + + currentCombatXp = newXp + if (difference > 10_000) return // TODO: find better value for max difference it can have + + tracker.modify { + it.combatXpGained += difference + } + } + + @SubscribeEvent + fun onPurseChange(event: PurseChangeEvent) { + if (!isEnabled()) return + if (event.reason != PurseChangeCause.GAIN_MOB_KILL) return + if (event.coins !in 200.0..2000.0) return + + tracker.addCoins(event.coins.toInt()) + } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!isEnabled()) return + itemDropPattern.matchMatcher(event.message) { + val internalName = NEUInternalName.fromItemNameOrNull(group("item")) ?: return + val mf = group("mf").formatInt() + if (!isAllowedItem(internalName)) return + + tracker.addItem(internalName, 1) + tracker.modify { + it.totalMagicFind += mf + it.totalMagicFindKills++ + + if (internalName == SORROW) { + it.ghostsSinceSorrow = 0 + } + } + return + } + killComboEndPattern.matchMatcher(event.message) { + val kill = group("kill").formatInt().toLong() + tracker.modify { + it.maxKillCombo = kill.coerceAtLeast(it.maxKillCombo) + } + return + } + if (bagOfCashPattern.matches(event.message)) { + tracker.addCoins(1_000_000) + return + } + } + + @SubscribeEvent + fun onTablistUpdate(event: TabListUpdateEvent) { + if (!isEnabled()) return + if (isMaxBestiary) return + event.tabList.forEach { line -> + bestiaryTablistPattern.matchMatcher(line) { + val level = group("level").formatInt() + val currentLevelKills = group("kills").formatInt().toLong() + + val kills = getTotalBestiaryKills(level, currentLevelKills) + if (kills <= currentBestiaryKills) return + val difference = kills - currentBestiaryKills + + if (difference > 50) { + currentBestiaryKills = kills + return + } + + currentBestiaryKills = kills + + tracker.modify { + it.kills += difference + it.ghostsSinceSorrow += difference + } + return + } + if (maxBestiaryTablistPattern.matches(line)) { + isMaxBestiary = true + currentBestiaryKills = MAX_BESTIARY_KILLS.toLong() + return + } + } + } + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent) { + if (!isEnabled()) return + + tracker.renderDisplay(config.trackerPosition) + } + + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + //allowedDrops = event.getConstant("GhostDrops").ghost_drops + allowedDrops = listOf( + SORROW, + "PLASMA".asInternalName(), + "VOLTA".asInternalName(), + "GHOST_BOOTS".asInternalName(), + ) + } + + @SubscribeEvent + fun onIslandChange(event: IslandChangeEvent) { + if (event.newIsland == IslandType.DWARVEN_MINES) { + tracker.firstUpdate() + } + } + + private fun isAllowedItem(internalName: NEUInternalName): Boolean = internalName in allowedDrops + + fun getAverageMagicFind(mf: Long, kills: Long) = if (mf == 0L || kills == 0L) 0.0 else mf / (kills).toDouble() + + + fun isEnabled() = IslandType.DWARVEN_MINES.isInIsland() && LorenzUtils.skyBlockArea == "The Mist" && config.enabled + + enum class GhostTrackerLines(private val display: String) { + TITLE("§e§lGhost Profit Tracker\""), + ITEMS( + " §723x §9Sorrow§7: §67.47M\n" + + " §713 §9Plasma§7: §6260k\n" + + " §741 §9Volta§7: §6195k\n" + ), + KILLS("§7Kills: §e7,813"), + GHOSTS_SINCE_SORROW("§7Ghosts Since Sorrow: §e71"), + MAX_KILL_COMBO("§7Max Kill Combo: §e681"), + COMBAT_XP_GAINED("§7Combat XP Gained: §e4,687,800"), + AVERAGE_MAGIC_FIND("§7Average Magic Find: §b278.9"), + BESTIARY_KILLS("§7Bestiary Kills: §e 71,893"), + TOTAL_PROFIT("§7Total Profit: §67,928,713 coins"), + ; + + override fun toString(): String { + return display + } + } + + private fun getTotalBestiaryKills(level: Int, kills: Long) = getBestiaryKillsUntilLevel(level) + kills + + private fun getBestiaryKillsUntilLevel(level: Int): Int { + var killsUntilLevel = 0 + for (i in 1..level) { + killsUntilLevel += getBestiaryKillsInLevel(i) + } + return killsUntilLevel + } + + private fun getBestiaryKillsInLevel(level: Int): Int { + return when (level) { + in 1..3 -> 5 + 4 -> 10 + 5 -> 25 + 6 -> 50 + 7 -> 100 + in 8..9 -> 150 + 10 -> 250 + 11 -> 750 + 12 -> 1_500 + 13 -> 2_000 + in 14..17 -> 2_500 + 18 -> 3_000 + in 19..20 -> 3_500 + 21 -> 25_000 + in 22..25 -> 50_000 + else -> 0 + } + } + +} From 5ee365fd172396afb2e8dcdb3f9b54de9a385e04 Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Fri, 10 May 2024 12:11:52 +0200 Subject: [PATCH 02/27] add support for roman levels in tablist Signed-off-by: Empa <42304516+ItsEmpa@users.noreply.github.com> --- .../skyhanni/features/combat/ghosttracker/GhostTracker.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index 3a30d5510683..7a9c2f66a256 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -20,6 +20,7 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatInt +import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches @@ -234,7 +235,7 @@ class GhostTracker { if (isMaxBestiary) return event.tabList.forEach { line -> bestiaryTablistPattern.matchMatcher(line) { - val level = group("level").formatInt() + val level = group("level").romanToDecimalIfNecessary() val currentLevelKills = group("kills").formatInt().toLong() val kills = getTotalBestiaryKills(level, currentLevelKills) From 19fbda9d6ae309cfa1d0d14be242129168cc21d5 Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Fri, 10 May 2024 12:16:50 +0200 Subject: [PATCH 03/27] more fixes Signed-off-by: Empa <42304516+ItsEmpa@users.noreply.github.com> --- .../skyhanni/features/combat/ghosttracker/GhostTracker.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index 7a9c2f66a256..7dfd91328a8f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -21,7 +21,6 @@ import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary -import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.matches import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern @@ -39,7 +38,6 @@ class GhostTracker { var currentCombatXp = 0L var currentBestiaryKills = 0L - var lastBestiaryUpdate = SimpleTimeMark.farPast() var isMaxBestiary = false private var allowedDrops = listOf() @@ -168,7 +166,7 @@ class GhostTracker { fun onProfileJoin(event: ProfileJoinEvent) { currentCombatXp = getCurrentCombatXp() ?: 0L currentBestiaryKills = storage?.bestiaryKills ?: 0 - isMaxBestiary = currentBestiaryKills >= 125_000 // TODO: actually get the max bestiary kills for ghosts + isMaxBestiary = currentBestiaryKills >= MAX_BESTIARY_KILLS } // TODO: Skill xp gain event @@ -192,7 +190,7 @@ class GhostTracker { fun onPurseChange(event: PurseChangeEvent) { if (!isEnabled()) return if (event.reason != PurseChangeCause.GAIN_MOB_KILL) return - if (event.coins !in 200.0..2000.0) return + if (event.coins !in 200.0..2_000.0) return tracker.addCoins(event.coins.toInt()) } From 52526b24153044a1f9b30210f3855c1e6a324f06 Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Fri, 31 May 2024 12:55:54 +0200 Subject: [PATCH 04/27] fix merge Signed-off-by: Empa <42304516+ItsEmpa@users.noreply.github.com> --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 5ed0b20b2815..8bc64190b57a 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -97,7 +97,6 @@ import at.hannibal2.skyhanni.features.combat.damageindicator.DamageIndicatorMana import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostCounter import at.hannibal2.skyhanni.features.combat.ghosttracker.GhostTracker -import at.hannibal2.skyhanni.features.combat.ghosttracker.GhostTracker import at.hannibal2.skyhanni.features.combat.mobs.AreaMiniBossFeatures import at.hannibal2.skyhanni.features.combat.mobs.AshfangMinisNametagHider import at.hannibal2.skyhanni.features.combat.mobs.MobHighlight From 081b5467d7ddbb325d4062544bf28267f5833f63 Mon Sep 17 00:00:00 2001 From: Empa <42304516+ItsEmpa@users.noreply.github.com> Date: Fri, 31 May 2024 13:00:00 +0200 Subject: [PATCH 05/27] use skill exp event Signed-off-by: Empa <42304516+ItsEmpa@users.noreply.github.com> --- .../combat/ghosttracker/GhostTracker.kt | 40 +++++++------------ 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index 7dfd91328a8f..0b913286ed3a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -10,9 +10,8 @@ import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.PurseChangeCause import at.hannibal2.skyhanni.events.PurseChangeEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent -import at.hannibal2.skyhanni.events.SecondPassedEvent +import at.hannibal2.skyhanni.events.SkillExpGainEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent -import at.hannibal2.skyhanni.features.skillprogress.SkillType import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.NEUInternalName @@ -21,8 +20,8 @@ import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher -import at.hannibal2.skyhanni.utils.StringUtils.matches +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import at.hannibal2.skyhanni.utils.tracker.ItemTrackerData import at.hannibal2.skyhanni.utils.tracker.SkyHanniItemTracker @@ -31,20 +30,16 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class GhostTracker { - val config get() = SkyHanniMod.feature.combat.ghostCounter + private val config get() = SkyHanniMod.feature.combat.ghostCounter val storage = ProfileStorageData.profileSpecific?.ghostStorage - var currentCombatXp = 0L - - var currentBestiaryKills = 0L - var isMaxBestiary = false + private var currentBestiaryKills = 0L + private var isMaxBestiary = false private var allowedDrops = listOf() - private val MAX_BESTIARY_KILLS = getBestiaryKillsUntilLevel(25) - - fun getCurrentCombatXp(): Long? = ProfileStorageData.profileSpecific?.skillData?.get(SkillType.COMBAT)?.totalXp + private val MAX_BESTIARY_KILLS by lazy { getBestiaryKillsUntilLevel(25) } private val tracker = SkyHanniItemTracker( "Ghost Tracker", @@ -164,25 +159,16 @@ class GhostTracker { @SubscribeEvent fun onProfileJoin(event: ProfileJoinEvent) { - currentCombatXp = getCurrentCombatXp() ?: 0L currentBestiaryKills = storage?.bestiaryKills ?: 0 isMaxBestiary = currentBestiaryKills >= MAX_BESTIARY_KILLS } - // TODO: Skill xp gain event @SubscribeEvent - fun onSecondPassed(event: SecondPassedEvent) { + fun onSkillExp(event: SkillExpGainEvent) { if (!isEnabled()) return - val newXp = getCurrentCombatXp() ?: return - if (newXp <= currentCombatXp) return - - val difference = newXp - currentCombatXp - - currentCombatXp = newXp - if (difference > 10_000) return // TODO: find better value for max difference it can have - + if (event.gained > 10_000) return tracker.modify { - it.combatXpGained += difference + it.combatXpGained += event.gained.toLong() } } @@ -288,10 +274,12 @@ class GhostTracker { private fun isAllowedItem(internalName: NEUInternalName): Boolean = internalName in allowedDrops - fun getAverageMagicFind(mf: Long, kills: Long) = if (mf == 0L || kills == 0L) 0.0 else mf / (kills).toDouble() + private fun getAverageMagicFind(mf: Long, kills: Long) = + if (mf == 0L || kills == 0L) 0.0 else mf / (kills).toDouble() - fun isEnabled() = IslandType.DWARVEN_MINES.isInIsland() && LorenzUtils.skyBlockArea == "The Mist" && config.enabled + private fun isEnabled() = + IslandType.DWARVEN_MINES.isInIsland() && LorenzUtils.skyBlockArea == "The Mist" && config.enabled enum class GhostTrackerLines(private val display: String) { TITLE("§e§lGhost Profit Tracker\""), From 029ea4cd16ebc81031b911eb0fee987a34385842 Mon Sep 17 00:00:00 2001 From: Cal Date: Thu, 6 Jun 2024 09:58:48 +1000 Subject: [PATCH 06/27] fix merge --- .../skyhanni/features/combat/ghosttracker/GhostTracker.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index 0b913286ed3a..2c7d34c0f8bb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -12,6 +12,7 @@ import at.hannibal2.skyhanni.events.PurseChangeEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.SkillExpGainEvent import at.hannibal2.skyhanni.events.TabListUpdateEvent +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.NEUInternalName @@ -28,7 +29,8 @@ import at.hannibal2.skyhanni.utils.tracker.SkyHanniItemTracker import com.google.gson.annotations.Expose import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class GhostTracker { +@SkyHanniModule +object GhostTracker { private val config get() = SkyHanniMod.feature.combat.ghostCounter @@ -332,5 +334,4 @@ class GhostTracker { else -> 0 } } - } From ef1789cb198a7a362ad64c3efef8b6caff370311 Mon Sep 17 00:00:00 2001 From: ItsEmpa Date: Wed, 2 Oct 2024 14:51:57 +0200 Subject: [PATCH 07/27] update stuff, make it work again, remove ghost counter code and configs, and add todo for migration Signed-off-by: ItsEmpa --- .../skyhanni/config/commands/Commands.kt | 8 +- .../config/features/combat/CombatConfig.java | 4 +- .../ghostcounter/GhostCounterConfig.java | 166 ------ .../GhostProfitTrackerConfig.java | 42 ++ .../BestiaryFormattingConfig.java | 41 -- .../textformatting/ETAFormattingConfig.java | 41 -- .../KillHourFormattingConfig.java | 24 - .../textformatting/TextFormattingConfig.java | 149 ----- .../XPHourFormattingConfig.java | 26 - .../storage/ProfileSpecificStorage.java | 1 + .../combat/ghostcounter/GhostCounter.kt | 529 ------------------ .../features/combat/ghostcounter/GhostData.kt | 84 +-- .../combat/ghostcounter/GhostFormatting.kt | 182 ------ .../features/combat/ghostcounter/GhostUtil.kt | 133 ----- .../combat/ghosttracker/GhostTracker.kt | 139 ++--- .../hannibal2/skyhanni/utils/CombatUtils.kt | 125 ----- .../utils/tracker/SkyHanniItemTracker.kt | 4 + 17 files changed, 120 insertions(+), 1578 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/GhostCounterConfig.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/GhostProfitTrackerConfig.java delete mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/BestiaryFormattingConfig.java delete mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/ETAFormattingConfig.java delete mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/KillHourFormattingConfig.java delete mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/TextFormattingConfig.java delete mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/XPHourFormattingConfig.java delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostFormatting.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostUtil.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 4974c80f2d51..1b9d9a584368 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -19,7 +19,7 @@ import at.hannibal2.skyhanni.features.bingo.card.nextstephelper.BingoNextStepHel import at.hannibal2.skyhanni.features.chat.ColorFormattingHelper import at.hannibal2.skyhanni.features.chat.translation.Translator import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil +import at.hannibal2.skyhanni.features.combat.ghosttracker.GhostTracker import at.hannibal2.skyhanni.features.commands.HelpCommand import at.hannibal2.skyhanni.features.commands.PartyChatCommands import at.hannibal2.skyhanni.features.commands.PartyCommands @@ -213,15 +213,11 @@ object Commands { "shclearslayerprofits", "Clearing the total slayer profit for the current slayer type", ) { SlayerProfitTracker.clearProfitCommand(it) } - registerCommand( - "shimportghostcounterdata", - "Manually importing the ghost counter data from GhostCounterV3", - ) { GhostUtil.importCTGhostCounterData() } registerCommand( "shclearfarmingitems", "Clear farming items saved for the Farming Fortune Guide", ) { clearFarmingItems() } - registerCommand("shresetghostcounter", "Resets the ghost counter") { GhostUtil.reset() } + registerCommand("shresetghosttracker", "Resets the ghost counter") { GhostTracker.reset() } registerCommand("shresetpowdertracker", "Resets the Powder Tracker") { PowderTracker.resetCommand() } registerCommand("shresetdicertracker", "Resets the Dicer Drop Tracker") { DicerRngDropTracker.resetCommand() } registerCommand("shresetcorpsetracker", "Resets the Glacite Mineshaft Corpse Tracker") { CorpseTracker.resetCommand() } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/combat/CombatConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/combat/CombatConfig.java index 7042b2fdbdd9..884e4c8049de 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/combat/CombatConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/combat/CombatConfig.java @@ -3,7 +3,7 @@ import at.hannibal2.skyhanni.config.FeatureToggle; import at.hannibal2.skyhanni.config.features.combat.broodmother.BroodmotherConfig; import at.hannibal2.skyhanni.config.features.combat.damageindicator.DamageIndicatorConfig; -import at.hannibal2.skyhanni.config.features.combat.ghostcounter.GhostCounterConfig; +import at.hannibal2.skyhanni.config.features.combat.ghostcounter.GhostProfitTrackerConfig; import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.Accordion; import io.github.notenoughupdates.moulconfig.annotations.Category; @@ -18,7 +18,7 @@ public class CombatConfig { @Expose @Category(name = "Ghost Counter", desc = "Ghost Counter settings") - public GhostCounterConfig ghostCounter = new GhostCounterConfig(); + public GhostProfitTrackerConfig ghostCounter = new GhostProfitTrackerConfig(); @Expose @ConfigOption(name = "Quiver", desc = "") diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/GhostCounterConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/GhostCounterConfig.java deleted file mode 100644 index 0d36a6bb3400..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/GhostCounterConfig.java +++ /dev/null @@ -1,166 +0,0 @@ -package at.hannibal2.skyhanni.config.features.combat.ghostcounter; - -import at.hannibal2.skyhanni.config.FeatureToggle; -import at.hannibal2.skyhanni.config.HasLegacyId; -import at.hannibal2.skyhanni.config.core.config.Position; -import at.hannibal2.skyhanni.config.features.combat.ghostcounter.textformatting.TextFormattingConfig; -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil; -import at.hannibal2.skyhanni.features.combat.ghosttracker.GhostTracker; -import com.google.gson.annotations.Expose; -import io.github.notenoughupdates.moulconfig.annotations.Accordion; -import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; -import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorButton; -import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDraggableList; -import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider; -import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; -import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static at.hannibal2.skyhanni.config.features.combat.ghostcounter.GhostCounterConfig.GhostDisplayEntry.AVG_MAGIC_FIND; -import static at.hannibal2.skyhanni.config.features.combat.ghostcounter.GhostCounterConfig.GhostDisplayEntry.GHOSTS_KILLED; -import static at.hannibal2.skyhanni.config.features.combat.ghostcounter.GhostCounterConfig.GhostDisplayEntry.GHOST_PER_SORROW; -import static at.hannibal2.skyhanni.config.features.combat.ghostcounter.GhostCounterConfig.GhostDisplayEntry.GHOST_SINCE_SORROW; -import static at.hannibal2.skyhanni.config.features.combat.ghostcounter.GhostCounterConfig.GhostDisplayEntry.HIGHEST_KILL_COMBO; -import static at.hannibal2.skyhanni.config.features.combat.ghostcounter.GhostCounterConfig.GhostDisplayEntry.KILL_COMBO; -import static at.hannibal2.skyhanni.config.features.combat.ghostcounter.GhostCounterConfig.GhostDisplayEntry.SCAVENGER_COINS; -import static at.hannibal2.skyhanni.config.features.combat.ghostcounter.GhostCounterConfig.GhostDisplayEntry.SORROW; -import static at.hannibal2.skyhanni.config.features.combat.ghostcounter.GhostCounterConfig.GhostDisplayEntry.TITLE; - -public class GhostCounterConfig { - - @Expose - @ConfigOption(name = "Enabled", desc = "Enable the ghost counter (invisible creepers within The Mist in the Dwarven Mines)") - @ConfigEditorBoolean - @FeatureToggle - public boolean enabled = true; - - @Expose - @ConfigOption( - name = "Display Text", - desc = "Drag text to change the appearance of the overlay." - ) - @ConfigEditorDraggableList - public List ghostTrackerText = new ArrayList<>(Arrays.asList( - GhostTracker.GhostTrackerLines.TITLE, - GhostTracker.GhostTrackerLines.ITEMS, - GhostTracker.GhostTrackerLines.KILLS, - GhostTracker.GhostTrackerLines.GHOSTS_SINCE_SORROW, - GhostTracker.GhostTrackerLines.MAX_KILL_COMBO, - GhostTracker.GhostTrackerLines.COMBAT_XP_GAINED, - GhostTracker.GhostTrackerLines.AVERAGE_MAGIC_FIND, - GhostTracker.GhostTrackerLines.BESTIARY_KILLS, - GhostTracker.GhostTrackerLines.TOTAL_PROFIT - )); - - @Expose - @ConfigOption( - name = "Display Text", - desc = "Drag text to change the appearance of the overlay." - ) - @ConfigEditorDraggableList - public List ghostDisplayText = new ArrayList<>(Arrays.asList( - TITLE, - GHOSTS_KILLED, - SORROW, - GHOST_SINCE_SORROW, - GHOST_PER_SORROW, - AVG_MAGIC_FIND, - SCAVENGER_COINS, - KILL_COMBO, - HIGHEST_KILL_COMBO - )); - - public enum GhostDisplayEntry implements HasLegacyId { - TITLE("§6Ghosts Counter", 0), - GHOSTS_KILLED(" §bGhost Killed: 42", 1), - SORROW(" §bSorrow: 6", 2), - GHOST_SINCE_SORROW(" §bGhost since Sorrow: 1", 3), - GHOST_PER_SORROW(" §bGhosts/Sorrow: 5", 4), - VOLTA(" §bVolta: 6", 5), - PLASMA(" §bPlasma: 8", 6), - GHOSTLY_BOOTS(" §bGhostly Boots: 1", 7), - BAG_OF_CASH(" §bBag Of Cash: 4", 8), - AVG_MAGIC_FIND(" §bAvg Magic Find: 271", 9), - SCAVENGER_COINS(" §bScavenger Coins: 15,000", 10), - KILL_COMBO(" §bKill Combo: 14", 11), - HIGHEST_KILL_COMBO(" §bHighest Kill Combo: 96", 12), - SKILL_XP_GAINED(" §bSkill XP Gained: 145,648", 13), - BESTIARY(" §bBestiary 1: 0/10", 14), - XP_PER_HOUR(" §bXP/h: 810,410", 15), - KILLS_PER_HOUR(" §bKills/h: 420", 16), - ETA(" §bETA: 14d", 17), - MONEY_PER_HOUR(" §bMoney/h: 13,420,069", 18), - MONEY_MADE(" §bMoney made: 14B", 19), - ; - - private final String str; - private final int legacyId; - - GhostDisplayEntry(String str, int legacyId) { - this.str = str; - this.legacyId = legacyId; - } - - // Constructor if new enum elements are added post-migration - GhostDisplayEntry(String str) { - this(str, -1); - } - - @Override - public int getLegacyId() { - return legacyId; - } - - @Override - public String toString() { - return str; - } - } - - @ConfigOption(name = "Text Formatting", desc = "") - @Accordion - @Expose - public TextFormattingConfig textFormatting = new TextFormattingConfig(); - - @Expose - @ConfigOption(name = "Extra Spaces", desc = "Spaces between each line of text.") - @ConfigEditorSlider( - minValue = -5, - maxValue = 10, - minStep = 1) - public int extraSpace = 1; - - @Expose - @ConfigOption(name = "Pause Timer", desc = "How many seconds to wait before pausing.") - @ConfigEditorSlider( - minValue = 1, - maxValue = 20, - minStep = 1 - ) - public int pauseTimer = 3; - - @Expose - @ConfigOption(name = "Show only in The Mist", desc = "Show the overlay only when you are in The Mist.") - @ConfigEditorBoolean - public boolean onlyOnMist = true; - - @Expose - @ConfigOption(name = "Max Bestiary", desc = "Show progress to max bestiary instead of next level.") - @ConfigEditorBoolean - public boolean showMax = false; - - @ConfigOption(name = "Reset", desc = "Reset the counter.") - @ConfigEditorButton(buttonText = "Reset") - public Runnable resetCounter = GhostUtil.INSTANCE::reset; - - @Expose - @ConfigLink(owner = GhostCounterConfig.class, field = "enabled") - public Position position = new Position(50, 50, false, true); - - @Expose - @ConfigLink(owner = GhostCounterConfig.class, field = "enabled") - public Position trackerPosition = new Position(50, 50, false, true); -} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/GhostProfitTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/GhostProfitTrackerConfig.java new file mode 100644 index 000000000000..93f66d175e03 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/GhostProfitTrackerConfig.java @@ -0,0 +1,42 @@ +package at.hannibal2.skyhanni.config.features.combat.ghostcounter; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.config.core.config.Position; +import at.hannibal2.skyhanni.features.combat.ghosttracker.GhostTracker; +import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDraggableList; +import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class GhostProfitTrackerConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Enables the Ghost Profit Tracker.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = true; + + @Expose + @ConfigOption( + name = "Display Text", + desc = "Drag text to change the appearance of the overlay." + ) + @ConfigEditorDraggableList + public List ghostTrackerText = new ArrayList<>(Arrays.asList( + GhostTracker.GhostTrackerLines.KILLS, + GhostTracker.GhostTrackerLines.GHOSTS_SINCE_SORROW, + GhostTracker.GhostTrackerLines.MAX_KILL_COMBO, + GhostTracker.GhostTrackerLines.COMBAT_XP_GAINED, + GhostTracker.GhostTrackerLines.AVERAGE_MAGIC_FIND, + GhostTracker.GhostTrackerLines.BESTIARY_KILLS + )); + + @Expose + @ConfigLink(owner = GhostProfitTrackerConfig.class, field = "enabled") + public Position position = new Position(50, 50, false, true); +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/BestiaryFormattingConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/BestiaryFormattingConfig.java deleted file mode 100644 index ac9f6e0b210a..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/BestiaryFormattingConfig.java +++ /dev/null @@ -1,41 +0,0 @@ -package at.hannibal2.skyhanni.config.features.combat.ghostcounter.textformatting; - -import com.google.gson.annotations.Expose; -import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorText; -import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; - -public class BestiaryFormattingConfig { - - @Expose - @ConfigOption(name = "Bestiary", desc = "Bestiary Progress line.\n" + - "§e%value% §7is replaced with your current progress to next level.\n" + - "§e%currentLevel% §7is replaced with your current bestiary level.\n" + - "§e%nextLevel% §7is replaced with your next bestiary level.\n" + - "§e%value% §7is replaced with one of the text below.") - @ConfigEditorText - public String base = " &6Bestiary %display%: &b%value%"; - - @Expose - @ConfigOption(name = "No Data", desc = "Text to show when you need to open the Bestiary Menu to gather data.") - @ConfigEditorText - public String openMenu = "§cOpen Bestiary Menu!"; - - @Expose - @ConfigOption(name = "Maxed", desc = "Text to show when your bestiary is at max level.\n" + - "§e%currentKill% §7is replaced with your current total kill.") - @ConfigEditorText - public String maxed = "%currentKill% (&c&lMaxed!)"; - - @Expose - @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%/100k (%percentNumber%%)"; - - @Expose - @ConfigOption(name = "Progress", desc = "Text to show progress when the §eMaxed Bestiary §7option is §cOFF\n" + - "§e%currentKill% §7is replaced with how many kills you have to the next level.\n" + - "§e%killNeeded% §7is replaced with how many kills you need to reach the next level.") - @ConfigEditorText - public String progress = "%currentKill%/%killNeeded%"; -} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/ETAFormattingConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/ETAFormattingConfig.java deleted file mode 100644 index 6e7d4766cfa1..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/ETAFormattingConfig.java +++ /dev/null @@ -1,41 +0,0 @@ -package at.hannibal2.skyhanni.config.features.combat.ghostcounter.textformatting; - -import com.google.gson.annotations.Expose; -import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorText; -import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; - -public class ETAFormattingConfig { - @Expose - @ConfigOption(name = "ETA to Next Level", desc = "ETA To Next Level line.\n" + - "§e%value% §7is replaced with one of the text below.") - @ConfigEditorText - public String base = " &6ETA: &b%value%"; - - @Expose - @ConfigOption(name = "Maxed!", desc = "Text to show when ghost bestiary is maxed.") - @ConfigEditorText - public String maxed = "&c&lMAXED!"; - - @Expose - @ConfigOption(name = "No Data", desc = "Text to show when there is no ETA.") - @ConfigEditorText - public String noData = "&bN/A"; - - @Expose - @ConfigOption(name = "Progress", desc = "Text to show progress to the next level.") - @ConfigEditorText - public String progress = "&b%value%"; - - @Expose - @ConfigOption(name = "Paused", desc = "Text displayed next to the time when paused.") - @ConfigEditorText - public String paused = "&c(PAUSED)"; - - @Expose - @ConfigOption(name = "Time", desc = "§e%days% §7is replaced with days remaining.\n" + - "§e%hours% §7is replaced with hours remaining.\n" + - "§e%minutes% §7is replaced with minutes remaining.\n" + - "§e%seconds% §7is replaced with seconds remaining.") - @ConfigEditorText - public String time = "&6%days%%hours%%minutes%%seconds%"; -} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/KillHourFormattingConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/KillHourFormattingConfig.java deleted file mode 100644 index b942278d31d3..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/KillHourFormattingConfig.java +++ /dev/null @@ -1,24 +0,0 @@ -package at.hannibal2.skyhanni.config.features.combat.ghostcounter.textformatting; - -import com.google.gson.annotations.Expose; -import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorText; -import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; - -public class KillHourFormattingConfig { - @Expose - @ConfigOption(name = "Kills/h", desc = "Kills per Hour line.\n" + - "§e%value% §7is replaced with the estimated kills per hour.") - @ConfigEditorText - public String base = " &6Kill/h: &b%value%"; - - @Expose - @ConfigOption(name = "No Data", desc = "Text to show when there is no Kills per Hour data.") - @ConfigEditorText - public String noData = "&bN/A"; - - @Expose - @ConfigOption(name = "Paused", desc = "Text displayed next to the time when paused.") - @ConfigEditorText - public String paused = "&c(PAUSED)"; -} - diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/TextFormattingConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/TextFormattingConfig.java deleted file mode 100644 index f33f4c7e8848..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/TextFormattingConfig.java +++ /dev/null @@ -1,149 +0,0 @@ -package at.hannibal2.skyhanni.config.features.combat.ghostcounter.textformatting; - -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostFormatting; -import com.google.gson.annotations.Expose; -import io.github.notenoughupdates.moulconfig.annotations.Accordion; -import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorButton; -import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorInfoText; -import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorText; -import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; - -public class TextFormattingConfig { - - @ConfigOption(name = "§eText Formatting Info", desc = "§e%session% §7is §e§lalways §7replaced with the count for your current session.\n" + - "§7It is reset when the game is restarted.\n" + - "§7You can use §e&Z §7color code to use SBA chroma.") - @ConfigEditorInfoText - public boolean formatInfo = false; - - @ConfigOption(name = "Reset Formatting", desc = "Reset formatting to default text.") - @ConfigEditorButton(buttonText = "Reset") - public Runnable resetFormatting = GhostFormatting.INSTANCE::reset; - - @ConfigOption(name = "Export Formatting", desc = "Export current formatting to clipboard.") - @ConfigEditorButton(buttonText = "Export") - public Runnable exportFormatting = GhostFormatting.INSTANCE::export; - - @ConfigOption(name = "Import Formatting", desc = "Import formatting from clipboard.") - @ConfigEditorButton(buttonText = "Import") - public Runnable importFormatting = GhostFormatting.INSTANCE::importFormat; - - @Expose - @ConfigOption(name = "Title", desc = "Title line.") - @ConfigEditorText - public String titleFormat = "&6Ghost Counter"; - - @Expose - @ConfigOption(name = "Ghosts killed", desc = "Ghosts killed line.\n" + - "§e%value% §7is replaced with Ghosts killed.\n" + - "§e%session% §7is replaced with Ghosts killed in this session.") - @ConfigEditorText - public String ghostKilledFormat = " &6Ghosts killed: &b%value% &7(%session%)"; - - @Expose - @ConfigOption(name = "Sorrows dropped", desc = "Sorrows dropped line.\n" + - "§e%value% §7is replaced with Sorrows dropped.") - @ConfigEditorText - public String sorrowsFormat = " &6Sorrows: &b%value% &7(%session%)"; - - @Expose - @ConfigOption(name = "Ghosts since Sorrow", desc = "Ghosts since Sorrow line.\n" + - "§e%value% §7is replaced with Ghosts since last Sorrow drop.") - @ConfigEditorText - public String ghostSinceSorrowFormat = " &6Ghosts since Sorrow: &b%value%"; - - @Expose - @ConfigOption(name = "Ghost kills per Sorrow", desc = "Ghost kills per Sorrow line.\n" + - "§e%value% §7is replaced with average Ghost kills per Sorrow drop.") - @ConfigEditorText - public String ghostKillPerSorrowFormat = " &6Ghosts/Sorrow: &b%value%"; - - @Expose - @ConfigOption(name = "Voltas dropped", desc = "Voltas dropped line.\n" + - "§e%value% §7is replaced with Voltas dropped.") - @ConfigEditorText - public String voltasFormat = " &6Voltas: &b%value% &7(%session%)"; - - @Expose - @ConfigOption(name = "Plasmas dropped", desc = "Plasmas dropped line.\n" + - "§e%value% §7is replaced with Plasmas dropped.") - @ConfigEditorText - public String plasmasFormat = " &6Plasmas: &b%value% &7(%session%)"; - - @Expose - @ConfigOption(name = "Ghostly Boots", desc = "Ghostly Boots dropped line.\n" + - "§e%value% §7is replaced with Ghostly Boots dropped.") - @ConfigEditorText - public String ghostlyBootsFormat = " &6Ghostly Boots: &b%value% &7(%session%)"; - - @Expose - @ConfigOption(name = "Bag Of Cash", desc = "Bag Of Cash dropped line.\n" + - "§e%value% §7is replaced with Bag Of Cash dropped.") - @ConfigEditorText - public String bagOfCashFormat = " &6Bag Of Cash: &b%value% &7(%session%)"; - - @Expose - @ConfigOption(name = "Average Magic Find", desc = "Average Magic Find line.\n" + - "§e%value% §7is replaced with Average Magic Find.") - @ConfigEditorText - public String avgMagicFindFormat = " &6Avg Magic Find: &b%value%"; - - @Expose - @ConfigOption(name = "Scavenger Coins", desc = "Scavenger Coins line.\n" + - "§e%value% §7is replaced with Coins earned from kill ghosts.\n" + - "Includes: Scavenger Enchant, Scavenger Talismans, Kill Combo") - @ConfigEditorText - public String scavengerCoinsFormat = " &6Scavenger Coins: &b%value% &7(%session%)"; - - @Expose - @ConfigOption(name = "Kill Combo", desc = "Kill Combo line.\n" + - "§e%value% §7is replaced with your current kill combo.") - @ConfigEditorText - public String killComboFormat = " &6Kill Combo: &b%value%"; - - @Expose - @ConfigOption(name = "Highest Kill Combo", desc = "Highest Kill Combo line.\n" + - "§e%value% §7is replaced with your highest kill combo.") - @ConfigEditorText - public String highestKillComboFormat = " &6Highest Kill Combo: &b%value% &7(%session%)"; - - @Expose - @ConfigOption(name = "Skill XP Gained", desc = "Skill XP Gained line.\n" + - "§e%value% §7is replaced with Skill XP Gained from killing Ghosts.") - @ConfigEditorText - public String skillXPGainFormat = " &6Skill XP Gained: &b%value% &7(%session%)"; - - @ConfigOption(name = "Bestiary Formatting", desc = "") - @Accordion - @Expose - public BestiaryFormattingConfig bestiaryFormatting = new BestiaryFormattingConfig(); - - @ConfigOption(name = "XP per Hour Formatting", desc = "") - @Accordion - @Expose - public XPHourFormattingConfig xpHourFormatting = new XPHourFormattingConfig(); - - @ConfigOption(name = "ETA Formatting", desc = "") - @Accordion - @Expose - public ETAFormattingConfig etaFormatting = new ETAFormattingConfig(); - - @ConfigOption(name = "Kills per Hour Formatting", desc = "") - @Expose - @Accordion - public KillHourFormattingConfig killHourFormatting = new KillHourFormattingConfig(); - - @Expose - @ConfigOption(name = "Money per Hour", desc = "Money per Hour.\n" + - "§e%value% §7is replaced with estimated money earned per hour.\n" + - "Calculated with your kills per hour and your average magic find.") - @ConfigEditorText - public String moneyHourFormat = " &6$/h: &b%value%"; - - @Expose - @ConfigOption(name = "Money made", desc = "Calculate the money you made.\n" + - "Includes §eSorrow§7, §ePlasma§7, §eVolta§7, §e1m coins drops§7, §eGhostly Boots§7, §eScavenger coins§7.\n" + - "§eUses current Sell Offer value.") - @ConfigEditorText - public String moneyMadeFormat = " &6Money made: &b%value%"; -} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/XPHourFormattingConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/XPHourFormattingConfig.java deleted file mode 100644 index aac56f59191f..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/textformatting/XPHourFormattingConfig.java +++ /dev/null @@ -1,26 +0,0 @@ -package at.hannibal2.skyhanni.config.features.combat.ghostcounter.textformatting; - -import com.google.gson.annotations.Expose; -import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorText; -import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; - -public class XPHourFormattingConfig { - - @Expose - @ConfigOption(name = "XP/h", desc = "XP per Hour line.\n" + - "§e%value% §7is replaced with one of the text below.") - @ConfigEditorText - public String base = " &6XP/h: &b%value%"; - - @Expose - @ConfigOption(name = "No Data", desc = "XP per Hour line.\n" + - "§e%value% §7is replaced with estimated amount of Combat XP you gain per hour.") - @ConfigEditorText - public String noData = "&bN/A"; - - @Expose - @ConfigOption(name = "Paused", desc = "Text displayed next to the time when paused.") - @ConfigEditorText - public String paused = "&c(PAUSED)"; -} - diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java index c44ec5329a10..243c46f65a1b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java @@ -482,6 +482,7 @@ public static class FarmingWeightConfig { public VinylType activeVinyl = null; } + // TODO: Merge data with GhostProfitTracker at a later date @Expose public GhostCounter ghostCounter = new GhostCounter(); diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt deleted file mode 100644 index b337d58b1487..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt +++ /dev/null @@ -1,529 +0,0 @@ -package at.hannibal2.skyhanni.features.combat.ghostcounter - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.config.features.combat.ghostcounter.GhostCounterConfig.GhostDisplayEntry -import at.hannibal2.skyhanni.data.IslandType -import at.hannibal2.skyhanni.data.ProfileStorageData -import at.hannibal2.skyhanni.data.SkillExperience -import at.hannibal2.skyhanni.events.ActionBarUpdateEvent -import at.hannibal2.skyhanni.events.ConfigLoadEvent -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.PurseChangeCause -import at.hannibal2.skyhanni.events.PurseChangeEvent -import at.hannibal2.skyhanni.events.SecondPassedEvent -import at.hannibal2.skyhanni.events.TabListUpdateEvent -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData.Option -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData.Option.KILLS -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData.bestiaryData -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.formatBestiary -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.formatText -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.isUsingCTGhostCounter -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.preFormat -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil.prettyTime -import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi.getBazaarData -import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule -import at.hannibal2.skyhanni.utils.ChatUtils -import at.hannibal2.skyhanni.utils.ChatUtils.chat -import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList -import at.hannibal2.skyhanni.utils.CombatUtils._isKilling -import at.hannibal2.skyhanni.utils.CombatUtils.calculateETA -import at.hannibal2.skyhanni.utils.CombatUtils.calculateXP -import at.hannibal2.skyhanni.utils.CombatUtils.interp -import at.hannibal2.skyhanni.utils.CombatUtils.isKilling -import at.hannibal2.skyhanni.utils.CombatUtils.killGainHour -import at.hannibal2.skyhanni.utils.CombatUtils.killGainHourLast -import at.hannibal2.skyhanni.utils.CombatUtils.lastKillUpdate -import at.hannibal2.skyhanni.utils.CombatUtils.lastUpdate -import at.hannibal2.skyhanni.utils.CombatUtils.xpGainHour -import at.hannibal2.skyhanni.utils.CombatUtils.xpGainHourLast -import at.hannibal2.skyhanni.utils.ConfigUtils -import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland -import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName -import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble -import at.hannibal2.skyhanni.utils.NumberUtil.formatLong -import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimal -import at.hannibal2.skyhanni.utils.NumberUtil.roundTo -import at.hannibal2.skyhanni.utils.OSUtils -import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher -import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems -import at.hannibal2.skyhanni.utils.StringUtils.removeColor -import at.hannibal2.skyhanni.utils.renderables.Renderable -import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern -import com.google.gson.JsonPrimitive -import io.github.moulberry.notenoughupdates.util.XPInformation -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import org.apache.commons.io.FilenameUtils -import java.io.File -import java.text.NumberFormat -import java.util.Locale -import kotlin.math.roundToInt -import kotlin.math.roundToLong - -@SkyHanniModule -object GhostCounter { - - val config get() = SkyHanniMod.feature.combat.ghostCounter - val storage get() = ProfileStorageData.profileSpecific?.ghostCounter - private var display = emptyList>() - var ghostCounterV3File = File(FilenameUtils.separatorsToSystem("./config/ChatTriggers/modules/GhostCounterV3/.persistantData.json")) - - private val patternGroup = RepoPattern.group("combat.ghostcounter") - private val skillXPPattern by patternGroup.pattern( - "skillxp", - "[+](?[0-9,.]+) \\((?[0-9,.]+)(?:/(?[0-9,.]+))?\\)", - ) - private val combatSectionPattern by patternGroup.pattern( - "combatsection", - ".*[+](?[0-9,.]+) (?[A-Za-z]+) \\((?(?[0-9.,]+)/(?[0-9.,]+)|(?[0-9.]+)%)\\).*", - ) - private val killComboExpiredPattern by patternGroup.pattern( - "killcomboexpired", - "§cYour Kill Combo has expired! You reached a (?.*) Kill Combo!", - ) - private val ghostXPPattern by patternGroup.pattern( - "ghostxp", - "(?\\d+(?:\\.\\d+)?(?:,\\d+)?[kK]?)/(?\\d+(?:\\.\\d+)?(?:,\\d+)?[kKmM]?)", - ) - private val bestiaryPattern by patternGroup.pattern( - "bestiary", - ".*(?:§\\d|§\\w)+BESTIARY (?:§\\d|§\\w)+Ghost (?:§\\d|§\\w)(?\\d+)➜(?:§\\d|§\\w)(?\\d+).*", - ) - private val skillLevelPattern by patternGroup.pattern( - "skilllevel", - ".*§e§lSkills: §r§a(?.*) (?\\d+).*", - ) - - private val format = NumberFormat.getInstance() - private var percent: Float = 0.0f - private var totalSkillXp = 0 - private var currentSkillXp = 0.0f - private var skillText = "" - private var lastParsedSkillSection = "" - private var lastSkillProgressString: String? = null - private var lastXp: Long = 0 - private var gain: Int = 0 - private var num: Double = 0.0 - private var inMist = false - private var notifyCTModule = true - var bestiaryCurrentKill = 0 - private var killETA = "" - private var currentSkill = "" - private var currentSkillLevel = -1 - private const val CONFIG_VALUE_VERSION = 1 - private val SORROW = "SORROW".asInternalName() - private val PLASMA = "PLASMA".asInternalName() - private val VOLTA = "VOLTA".asInternalName() - - @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) { - if (!isEnabled()) return - if (config.onlyOnMist && !inMist) return - config.position.renderStringsAndItems( - display, - extraSpace = config.extraSpace, - posLabel = "Ghost Counter", - ) - } - - private fun formatDisplay(map: List>): List> { - val newList = mutableListOf>() - for (index in config.ghostDisplayText) { - // TODO, change functionality to use enum rather than ordinals - newList.add(map[index.ordinal]) - } - return newList - } - - fun update() { - display = formatDisplay(drawDisplay()) - } - - private fun drawDisplay() = buildList> { - val textFormatting = config.textFormatting - val ghostKillPerSorrow: Int = when (Option.SORROWCOUNT.get()) { - 0.0 -> 0 - else -> "${((((KILLS.get() / Option.SORROWCOUNT.get()) + Math.ulp(1.0)) * 100) / 100).roundToInt()}".toInt() - } - val avgMagicFind = when (Option.TOTALDROPS.get()) { - 0.0 -> "0" - else -> { - val mf = (((storage?.totalMF!! / Option.TOTALDROPS.get()) + Math.ulp(1.0)) * 100) / 100 - mf.roundTo(2).toString() - } - } - - val xpHourFormatting = textFormatting.xpHourFormatting - val xpInterp: Float - val xp = if (xpGainHourLast == xpGainHour && xpGainHour <= 0) { - xpHourFormatting.noData - } else { - xpInterp = interp(xpGainHour, xpGainHourLast, lastUpdate) - val part = "([0-9]{3,}[^,]+)".toRegex().find(format.format(xpInterp))?.groupValues?.get(1) ?: "N/A" - "$part ${if (isKilling) "" else xpHourFormatting.paused}" - } - - val killHourFormatting = textFormatting.killHourFormatting - val killHour: String - var killInterp: Long = 0 - if (killGainHourLast == killGainHour && killGainHour <= 0) { - killHour = killHourFormatting.noData - } else { - killInterp = interp(killGainHour.toFloat(), killGainHourLast.toFloat(), lastKillUpdate).toLong() - killHour = "${format.format(killInterp)} ${if (_isKilling) "" else killHourFormatting.paused}" - } - - val bestiaryFormatting = textFormatting.bestiaryFormatting - val currentKill = storage?.bestiaryCurrentKill?.toInt() ?: 0 - val killNeeded = storage?.bestiaryKillNeeded?.toInt() ?: 0 - val nextLevel = storage?.bestiaryNextLevel?.toInt() ?: -1 - val bestiary = if (config.showMax) { - when (nextLevel) { - 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) { - 26 -> bestiaryFormatting.maxed - in 1..25 -> bestiaryFormatting.progress - else -> bestiaryFormatting.openMenu - } - } - - val etaFormatting = textFormatting.etaFormatting - val remaining: Int = when (config.showMax) { - true -> 100_000 - bestiaryCurrentKill - false -> killNeeded - currentKill - } - - val eta = if (remaining < 0) { - etaFormatting.maxed - } else { - if (killGainHour < 1) { - etaFormatting.noData - } else { - val timeMap = prettyTime(remaining.toLong() * 1000 * 60 * 60 / killInterp) - val time = buildString { - if (timeMap.isNotEmpty()) { - val formatMap = mapOf( - "%days%" to "days", - "%hours%" to "hours", - "%minutes%" to "minutes", - "%seconds%" to "seconds", - ) - for ((format, key) in formatMap) { - if (etaFormatting.time.contains(format)) { - timeMap[key]?.let { value -> - append("$value${format[1]}") - } - } - } - } else { - append("§cEnded!") - } - } - killETA = time - etaFormatting.progress + if (_isKilling) "" else etaFormatting.paused - } - } - - addAsSingletonList(textFormatting.titleFormat.replace("&", "§")) - addAsSingletonList(textFormatting.ghostKilledFormat.formatText(KILLS)) - addAsSingletonList(textFormatting.sorrowsFormat.formatText(Option.SORROWCOUNT)) - addAsSingletonList(textFormatting.ghostSinceSorrowFormat.formatText(Option.GHOSTSINCESORROW.getInt())) - addAsSingletonList(textFormatting.ghostKillPerSorrowFormat.formatText(ghostKillPerSorrow)) - addAsSingletonList(textFormatting.voltasFormat.formatText(Option.VOLTACOUNT)) - addAsSingletonList(textFormatting.plasmasFormat.formatText(Option.PLASMACOUNT)) - addAsSingletonList(textFormatting.ghostlyBootsFormat.formatText(Option.GHOSTLYBOOTS)) - addAsSingletonList(textFormatting.bagOfCashFormat.formatText(Option.BAGOFCASH)) - addAsSingletonList(textFormatting.avgMagicFindFormat.formatText(avgMagicFind)) - addAsSingletonList(textFormatting.scavengerCoinsFormat.formatText(Option.SCAVENGERCOINS)) - addAsSingletonList(textFormatting.killComboFormat.formatText(Option.MAXKILLCOMBO)) - addAsSingletonList(textFormatting.highestKillComboFormat.formatText(Option.MAXKILLCOMBO)) - addAsSingletonList(textFormatting.skillXPGainFormat.formatText(Option.SKILLXPGAINED)) - 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)) - - val rate = 0.12 * (1 + (avgMagicFind.toDouble() / 100)) - val sorrowValue = SORROW.getBazaarData()?.sellOfferPrice?.toLong() ?: 0L - val final: String = (killInterp * sorrowValue * (rate / 100)).toLong().addSeparators() - val plasmaValue = PLASMA.getBazaarData()?.sellOfferPrice?.toLong() ?: 0L - val voltaValue = VOLTA.getBazaarData()?.sellOfferPrice?.toLong() ?: 0L - var moneyMade: Long = 0 - val priceMap = listOf( - Triple("Sorrow", Option.SORROWCOUNT.getInt(), sorrowValue), - Triple("Plasma", Option.PLASMACOUNT.getInt(), plasmaValue), - Triple("Volta", Option.VOLTACOUNT.getInt(), voltaValue), - Triple("Bag Of Cash", Option.BAGOFCASH.getInt(), 1_000_000), - Triple("Scavenger Coins", Option.SCAVENGERCOINS.getInt(), 1), - Triple("Ghostly Boots", Option.GHOSTLYBOOTS.getInt(), 77_777), - ) - val moneyMadeTips = buildList { - for ((name, count, value) in priceMap) { - moneyMade += (count.toLong() * value.toLong()) - add("$name: §b${value.addSeparators()} §fx §b${count.addSeparators()} §f= §6${(value.toLong() * count.toLong()).addSeparators()}") - } - add("§bTotal: §6${moneyMade.addSeparators()}") - add("§eClick to copy to clipboard!") - } - val moneyMadeWithClickableTips = Renderable.clickAndHover( - textFormatting.moneyMadeFormat.formatText(moneyMade.addSeparators()), - moneyMadeTips, - onClick = { OSUtils.copyToClipboard(moneyMadeTips.joinToString("\n").removeColor()) }, - ) - addAsSingletonList(textFormatting.moneyHourFormat.formatText(final)) - addAsSingletonList(moneyMadeWithClickableTips) - } - - @SubscribeEvent - fun onSecondPassed(event: SecondPassedEvent) { - if (!isEnabled()) return - - skillXPPattern.matchMatcher(skillText) { - val gained = group("gained").formatDouble() - val current = group("current").formatLong() - if (current != lastXp) { - gain = (current - lastXp).toDouble().roundToInt() - num = (gain.toDouble() / gained) - if (gained in 150.0..450.0 && lastXp != 0L && num >= 0) { - KILLS.add(num) - KILLS.add(num, true) - Option.GHOSTSINCESORROW.add(num) - Option.KILLCOMBO.add(num) - Option.SKILLXPGAINED.add(gained * num.roundToLong()) - Option.SKILLXPGAINED.add(gained * num.roundToLong(), true) - storage?.bestiaryCurrentKill = storage?.bestiaryCurrentKill?.plus(num) ?: num - } - lastXp = current - } - } - - if (notifyCTModule && ProfileStorageData.profileSpecific?.ghostCounter?.ctDataImported != true) { - notifyCTModule = false - if (isUsingCTGhostCounter()) { - ChatUtils.clickableChat( - "GhostCounterV3 ChatTriggers module has been detected, do you want to import saved data? Click here to import data", - onClick = { - GhostUtil.importCTGhostCounterData() - }, - "§eClick to import data!", - prefixColor = "§6", - oneTimeClick = true, - ) - } - } - - inMist = LorenzUtils.skyBlockArea == "The Mist" - update() - - if (event.repeatSeconds(2)) { - calculateXP() - calculateETA() - } - } - - @SubscribeEvent - fun onActionBarUpdate(event: ActionBarUpdateEvent) { - if (!isEnabled()) return - if (!inMist) return - combatSectionPattern.matchMatcher(event.actionBar) { - if (group("skillName").lowercase() != "combat") return - parseCombatSection(event.actionBar) - } - } - - private fun parseCombatSection(section: String) { - val sb = StringBuilder() - val nf = NumberFormat.getInstance(Locale.US) - nf.maximumFractionDigits = 2 - if (lastParsedSkillSection == section) { - sb.append(lastSkillProgressString) - } else if (combatSectionPattern.matcher(section).find()) { - combatSectionPattern.matchMatcher(section) { - sb.append("+").append(group("gained")) - val skillName = group("skillName") - val skillPercent = group("percent") != null - 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 - if (level > 0) { - totalSkillXp = SkillExperience.getExpForNextLevel(level) - currentSkillXp = totalSkillXp * percent / 100 - } else { - parse = false - } - } else { - currentSkillXp = nf.parse(group("current")).toFloat() - totalSkillXp = nf.parse(group("total")).toInt() - } - percent = 100f.coerceAtMost(percent) - if (!parse) { - sb.append(" (").append(String.format("%.2f", percent)).append("%)") - } else { - sb.append(" (").append(nf.format(currentSkillXp)) - if (totalSkillXp != 0) { - sb.append("/") - sb.append(nf.format(totalSkillXp)) - } - sb.append(")") - } - lastParsedSkillSection = section - lastSkillProgressString = sb.toString() - } - if (sb.toString().isNotEmpty()) { - skillText = sb.toString() - } - } - } - - @SubscribeEvent - fun onTabListUpdate(event: TabListUpdateEvent) { - if (!isEnabled()) return - for (line in event.tabList) { - skillLevelPattern.matchMatcher(line) { - currentSkill = group("skillName") - currentSkillLevel = group("skillLevel").toInt() - } - } - } - - @SubscribeEvent - fun onChat(event: LorenzChatEvent) { - if (!isEnabled()) return - for (opt in Option.entries) { - val pattern = opt.pattern ?: continue - pattern.matchMatcher(event.message) { - when (opt) { - Option.SORROWCOUNT, Option.VOLTACOUNT, Option.PLASMACOUNT, Option.GHOSTLYBOOTS -> { - opt.add(1.0) - opt.add(1.0, true) - storage?.totalMF = - storage?.totalMF?.plus(group("mf").substring(4).toDouble()) ?: group("mf").substring(4).toDouble() - Option.TOTALDROPS.add(1.0) - if (opt == Option.SORROWCOUNT) Option.GHOSTSINCESORROW.set(0.0) - update() - } - - Option.BAGOFCASH -> { - Option.BAGOFCASH.add(1.0) - Option.BAGOFCASH.add(1.0, true) - update() - } - - Option.KILLCOMBOCOINS -> { - Option.KILLCOMBOCOINS.set(Option.KILLCOMBOCOINS.get() + group("coin").toDouble()) - update() - } - - else -> {} - } - } - } - killComboExpiredPattern.matchMatcher(event.message) { - if (Option.KILLCOMBO.getInt() > Option.MAXKILLCOMBO.getInt()) { - Option.MAXKILLCOMBO.set(group("combo").formatDouble()) - } - if (Option.KILLCOMBO.getInt() > Option.MAXKILLCOMBO.getInt(true)) { - Option.MAXKILLCOMBO.set(group("combo").formatDouble(), true) - } - Option.KILLCOMBOCOINS.set(0.0) - Option.KILLCOMBO.set(0.0) - update() - } - // replace with BestiaryLevelUpEvent ? - bestiaryPattern.matchMatcher(event.message) { - val currentLevel = group("nextLevel").toInt() - when (val nextLevel = if (currentLevel >= 25) 26 else currentLevel + 1) { - 26 -> { - storage?.bestiaryNextLevel = 26.0 - storage?.bestiaryCurrentKill = 100_000.0 - storage?.bestiaryKillNeeded = 0.0 - } - - else -> { - val killNeeded: Int = bestiaryData[nextLevel] ?: -1 - storage?.bestiaryNextLevel = nextLevel.toDouble() - storage?.bestiaryCurrentKill = 0.0 - storage?.bestiaryKillNeeded = killNeeded.toDouble() - } - } - update() - } - } - - @SubscribeEvent - fun onPurseChange(event: PurseChangeEvent) { - if (!isEnabled()) return - if (LorenzUtils.skyBlockArea != "The Mist") return - if (event.reason != PurseChangeCause.GAIN_MOB_KILL) return - Option.SCAVENGERCOINS.add(event.coins, true) - Option.SCAVENGERCOINS.add(event.coins) - } - - @SubscribeEvent - fun onInventoryOpen(event: InventoryFullyOpenedEvent) { - if (!LorenzUtils.inSkyBlock) return - val inventoryName = event.inventoryName - if (inventoryName != "Bestiary ➜ Dwarven Mines") return - val stacks = event.inventoryItems - val ghostStack = stacks.values.find { it.displayName.contains("Ghost") } ?: return - val bestiaryNextLevel = - if ("§\\wGhost".toRegex().matches(ghostStack.displayName)) 1 else ghostStack.displayName.substring(8).romanToDecimal() + 1 - storage?.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)?.formatDouble() ?: 0.0 - } - ghostXPPattern.matchMatcher(line.removeColor().trim()) { - storage?.bestiaryCurrentKill = if (kills > 0) kills else group("current").formatDouble() - storage?.bestiaryKillNeeded = group("total").formatDouble() - } - } - update() - } - - @SubscribeEvent - fun onConfigLoad(event: ConfigLoadEvent) { - if (storage?.configUpdateVersion == 0) { - config.textFormatting.bestiaryFormatting.base = " &6Bestiary %display%: &b%value%" - chat("Your GhostCounter config has been automatically adjusted.") - storage?.configUpdateVersion = CONFIG_VALUE_VERSION - } - } - - @SubscribeEvent - fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.move(2, "ghostCounter", "combat.ghostCounter") - event.transform(11, "combat.ghostCounter.ghostDisplayText") { element -> - ConfigUtils.migrateIntArrayListToEnumArrayList(element, GhostDisplayEntry::class.java) - } - - event.transform(58, "combat.ghostCounter.textFormatting.bestiaryFormatting.showMax_progress") { - JsonPrimitive("%currentKill%/100k (%percentNumber%%)") - } - } - - fun isEnabled() = IslandType.DWARVEN_MINES.isInIsland() && config.enabled -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostData.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostData.kt index fde0f51dac1c..18fffae12547 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostData.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostData.kt @@ -1,86 +1,20 @@ package at.hannibal2.skyhanni.features.combat.ghostcounter -import java.util.regex.Pattern -import kotlin.math.roundToInt - object GhostData { - private var session = mutableMapOf( - Option.KILLS to 0.0, - Option.SORROWCOUNT to 0.0, - Option.VOLTACOUNT to 0.0, - Option.PLASMACOUNT to 0.0, - Option.GHOSTLYBOOTS to 0.0, - Option.BAGOFCASH to 0.0, - Option.TOTALDROPS to 0.0, - Option.SCAVENGERCOINS to 0.0, - Option.MAXKILLCOMBO to 0.0, - Option.SKILLXPGAINED to 0.0 - ) - - // TODO repo - val bestiaryData = mutableMapOf().apply { - for (i in 1..25) { - this[i] = when (i) { - 1, 2, 3, 4, 5 -> 4 - 6 -> 20 - 7 -> 40 - 8, 9 -> 60 - 10 -> 100 - 11 -> 300 - 12 -> 600 - 13 -> 800 - 14, 15, 16, 17 -> 1_000 - 18 -> 1_200 - 19, 20 -> 1_400 - 21 -> 10_000 - 22, 23, 24, 25 -> 20_000 - else -> 0 - } - } - } - - enum class Option(val pattern: Pattern? = null) { + enum class Option { KILLS, - SORROWCOUNT("§6§lRARE DROP! §r§9Sorrow §r§b\\([+](?.*)% §r§b✯ Magic Find§r§b\\)".toPattern()), - VOLTACOUNT("§6§lRARE DROP! §r§9Volta §r§b\\([+](?.*)% §r§b✯ Magic Find§r§b\\)".toPattern()), - PLASMACOUNT("§6§lRARE DROP! §r§9Plasma §r§b\\([+](?.*)% §r§b✯ Magic Find§r§b\\)".toPattern()), - GHOSTLYBOOTS("§6§lRARE DROP! §r§9Ghostly Boots §r§b\\([+](?.*)% §r§b✯ Magic Find§r§b\\)".toPattern()), - BAGOFCASH("§eThe ghost's death materialized §r§61,000,000 coins §r§efrom the mists!".toPattern()), - KILLCOMBOCOINS("[+]\\d+ Kill Combo [+](?.*) coins per kill".toPattern()), + SORROWCOUNT, + VOLTACOUNT, + PLASMACOUNT, + GHOSTLYBOOTS, + BAGOFCASH, + KILLCOMBOCOINS, TOTALDROPS, GHOSTSINCESORROW, SCAVENGERCOINS, MAXKILLCOMBO, - KILLCOMBO("[+]\\d+ Kill Combo [+](?.*) coins per kill".toPattern()), - SKILLXPGAINED; - - fun add(i: Double, s: Boolean = false) { - if (s) - session[this] = session[this]?.plus(i) ?: i - else - GhostCounter.storage?.data?.set(this, GhostCounter.storage?.data?.get(this)?.plus(i) ?: i) - } - - fun set(i: Double, s: Boolean = false) { - if (s) - session[this] = i - else - GhostCounter.storage?.data?.set(this, i) - } - - fun getInt(s: Boolean = false): Int { - return if (s) - session[this]?.roundToInt() ?: 0 - else - GhostCounter.storage?.data?.get(this)?.roundToInt() ?: 0 - } - - fun get(s: Boolean = false): Double { - return if (s) - session[this] ?: 0.0 - else - GhostCounter.storage?.data?.get(this) ?: 0.0 - } + KILLCOMBO, + SKILLXPGAINED, } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostFormatting.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostFormatting.kt deleted file mode 100644 index b58201899bc4..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostFormatting.kt +++ /dev/null @@ -1,182 +0,0 @@ -package at.hannibal2.skyhanni.features.combat.ghostcounter - -import com.google.gson.JsonArray -import com.google.gson.JsonParser -import com.google.gson.JsonPrimitive -import java.awt.Toolkit -import java.awt.datatransfer.DataFlavor -import java.awt.datatransfer.StringSelection -import java.nio.charset.StandardCharsets -import java.util.Base64 - -object GhostFormatting { - - private const val exportPrefix = "gc/" - - fun importFormat() { - val base64: String = try { - Toolkit.getDefaultToolkit().systemClipboard.getData(DataFlavor.stringFlavor) as String - } catch (e: Exception) { - return - } - - if (base64.length <= exportPrefix.length) return - val jsonString = try { - val t = String(Base64.getDecoder().decode(base64.trim())) - if (!t.startsWith(exportPrefix)) return - t.substring(exportPrefix.length) - } catch (e: IllegalArgumentException) { - return - } - - val list = try { - JsonParser().parse(jsonString).asJsonArray - .filter { it.isJsonPrimitive } - .map { it.asString } - } catch (e: Exception) { - return - } - - if (list.isNotEmpty()) { - with(GhostCounter.config.textFormatting) { - titleFormat = list[0] - ghostKilledFormat = list[1] - sorrowsFormat = list[2] - ghostSinceSorrowFormat = list[3] - ghostKillPerSorrowFormat = list[4] - voltasFormat = list[5] - plasmasFormat = list[6] - ghostlyBootsFormat = list[7] - bagOfCashFormat = list[8] - avgMagicFindFormat = list[9] - scavengerCoinsFormat = list[10] - killComboFormat = list[11] - highestKillComboFormat = list[12] - skillXPGainFormat = list[13] - with(xpHourFormatting) { - base = list[14] - noData = list[15] - paused = list[16] - } - with(bestiaryFormatting) { - base = list[17] - openMenu = list[18] - maxed = list[19] - showMax_progress = list[20] - progress = list[21] - } - with(killHourFormatting) { - base = list[22] - noData = list[23] - paused = list[24] - } - with(etaFormatting) { - base = list[25] - maxed = list[26] - noData = list[27] - progress = list[28] - time = list[29] - } - moneyHourFormat = list[30] - moneyMadeFormat = list[31] - } - } - } - - fun export() { - val list = mutableListOf() - with(GhostCounter.config.textFormatting) { - list.add(titleFormat) - list.add(ghostKilledFormat) - list.add(sorrowsFormat) - list.add(ghostSinceSorrowFormat) - list.add(ghostKillPerSorrowFormat) - list.add(voltasFormat) - list.add(plasmasFormat) - list.add(ghostlyBootsFormat) - list.add(bagOfCashFormat) - list.add(avgMagicFindFormat) - list.add(scavengerCoinsFormat) - list.add(killComboFormat) - list.add(highestKillComboFormat) - list.add(skillXPGainFormat) - with(xpHourFormatting) { - list.add(base) - list.add(noData) - list.add(paused) - } - with(bestiaryFormatting) { - list.add(base) - list.add(openMenu) - list.add(maxed) - list.add(showMax_progress) - list.add(progress) - } - with(killHourFormatting) { - list.add(base) - list.add(noData) - list.add(paused) - } - with(etaFormatting) { - list.add(base) - list.add(maxed) - list.add(noData) - list.add(progress) - list.add(time) - } - list.add(moneyHourFormat) - list.add(moneyMadeFormat) - } - val jsonArray = JsonArray() - for (l in list) { - jsonArray.add(JsonPrimitive(l)) - } - val base64 = Base64.getEncoder().encodeToString((exportPrefix + jsonArray).toByteArray(StandardCharsets.UTF_8)) - Toolkit.getDefaultToolkit().systemClipboard.setContents(StringSelection(base64), null) - } - - fun reset() { - with(GhostCounter.config.textFormatting) { - titleFormat = "&6Ghost Counter" - ghostKilledFormat = " &6Ghosts Killed: &b%value% &7(%session%)" - sorrowsFormat = " &6Sorrow: &b%value% &7(%session%)" - ghostSinceSorrowFormat = " &6Ghost since Sorrow: &b%value%" - ghostKillPerSorrowFormat = " &6Ghosts/Sorrow: &b%value%" - voltasFormat = " &6Volta: &b%value% &7(%session%)" - plasmasFormat = " &6Plasmas: &b%value% &7(%session%)" - ghostlyBootsFormat = " &6Ghostly Boots: &b%value% &7(%session%)" - bagOfCashFormat = " &6Bag Of Cash: &b%value% &7(%session%)" - avgMagicFindFormat = " &6Avg Magic Find: &b%value%" - scavengerCoinsFormat = " &6Scavenger Coins: &b%value% &7(%session%)" - killComboFormat = " &6Kill Combo: &b%value%" - highestKillComboFormat = " &6Highest Kill Combo: &b%value% &7(%session%)" - skillXPGainFormat = " &6Skill XP Gained: &b%value% &7(%session%)" - with(xpHourFormatting) { - base = " &6XP/h: &b%value%" - noData = "&bN/A" - paused = "&c(PAUSED)" - } - with(bestiaryFormatting) { - base = " &6Bestiary %currentLevel%->%nextLevel%: &b%value%" - openMenu = "§cOpen Bestiary Menu !" - maxed = "%currentKill% (&c&lMaxed!)" - showMax_progress = "%currentKill%/100k (%percentNumber%%)" - progress = "%currentKill%/%killNeeded%" - } - with(killHourFormatting) { - base = " &6Kill/h: &b%value%" - noData = "§bN/A" - paused = "&c(PAUSED)" - } - with(etaFormatting) { - base = " &6ETA: &b%value%" - maxed = "§c§lMAXED!" - noData = "§bN/A" - progress = "§b%value%" - time = "&6%days%%hours%%minutes%%seconds%" - } - moneyHourFormat = " &6$/h: &b%value%" - moneyMadeFormat = " &6Money made: &b%value%" - } - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostUtil.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostUtil.kt deleted file mode 100644 index 36a4edfb3cd4..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostUtil.kt +++ /dev/null @@ -1,133 +0,0 @@ -package at.hannibal2.skyhanni.features.combat.ghostcounter - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.config.ConfigManager -import at.hannibal2.skyhanni.data.ProfileStorageData -import at.hannibal2.skyhanni.test.command.ErrorManager -import at.hannibal2.skyhanni.utils.ChatUtils -import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators -import at.hannibal2.skyhanni.utils.NumberUtil.roundTo -import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat -import java.io.FileReader - -object GhostUtil { - - fun reset() { - for (opt in GhostData.Option.entries) { - opt.set(0.0) - opt.set(0.0, true) - } - GhostCounter.storage?.totalMF = 0.0 - GhostCounter.update() - } - - fun isUsingCTGhostCounter(): Boolean { - return GhostCounter.ghostCounterV3File.exists() && GhostCounter.ghostCounterV3File.isFile - } - - fun prettyTime(millis: Long): Map { - val seconds = millis / 1000 % 60 - val minutes = millis / 1000 / 60 % 60 - val hours = millis / 1000 / 60 / 60 % 24 - val days = millis / 1000 / 60 / 60 / 24 - return buildMap { - when { - millis < 0 -> { - clear() - } - - minutes == 0L && hours == 0L && days == 0L -> { - put("seconds", seconds.toString()) - } - - hours == 0L && days == 0L -> { - put("seconds", seconds.toString()) - put("minutes", minutes.toString()) - } - - days == 0L -> { - put("seconds", seconds.toString()) - put("minutes", minutes.toString()) - put("hours", hours.toString()) - } - - else -> { - put("seconds", seconds.toString()) - put("minutes", minutes.toString()) - put("hours", hours.toString()) - put("days", days.toString()) - } - } - } - } - - fun importCTGhostCounterData() { - val c = ProfileStorageData.profileSpecific?.ghostCounter ?: return - if (isUsingCTGhostCounter()) { - if (c.ctDataImported) { - ChatUtils.userError("You already imported GhostCounterV3 data!") - return - } - val json = ConfigManager.gson.fromJson( - FileReader(GhostCounter.ghostCounterV3File), - com.google.gson.JsonObject::class.java, - ) - GhostData.Option.GHOSTSINCESORROW.add(json["ghostsSinceSorrow"].asDouble) - GhostData.Option.SORROWCOUNT.add(json["sorrowCount"].asDouble) - GhostData.Option.BAGOFCASH.add(json["BagOfCashCount"].asDouble) - GhostData.Option.PLASMACOUNT.add(json["PlasmaCount"].asDouble) - GhostData.Option.VOLTACOUNT.add(json["VoltaCount"].asDouble) - GhostData.Option.GHOSTLYBOOTS.add(json["GhostlyBootsCount"].asDouble) - GhostData.Option.KILLS.add(json["ghostsKilled"].asDouble) - GhostCounter.storage?.totalMF = GhostCounter.storage?.totalMF?.plus(json["TotalMF"].asDouble) - ?: json["TotalMF"].asDouble - GhostData.Option.TOTALDROPS.add(json["TotalDrops"].asDouble) - c.ctDataImported = true - ChatUtils.chat("§aImported data successfully!") - } else - ErrorManager.skyHanniError("GhostCounterV3 ChatTriggers module not found!") - } - - fun String.formatText(option: GhostData.Option) = formatText(option.getInt(), option.getInt(true)) - - fun String.formatText(value: Int, session: Int = -1) = this.replace("%value%", value.addSeparators()) - .replace("%session%", session.addSeparators()) - .replace("&", "§") - - fun String.formatText(t: String) = this.replace("%value%", t).replace("&", "§") - - fun String.preFormat(t: String, level: Int, nextLevel: Int) = if (nextLevel == 26) { - replace("%value%", t).replace("%display%", "25") - } else { - this.replace("%value%", t) - .replace( - "%display%", - "$level->${if (SkyHanniMod.feature.combat.ghostCounter.showMax) "25" else nextLevel}", - ) - } - - fun String.formatText(value: Double, session: Double) = this.replace("%value%", value.roundTo(2).addSeparators()) - .replace("%session%", session.roundTo(2).addSeparators()) - .replace("&", "§") - - fun String.formatBestiary(currentKill: Int, killNeeded: Int): String { - val bestiaryNextLevel = GhostCounter.storage?.bestiaryNextLevel - val currentLevel = - 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 this.replace( - "%currentKill%", - if (GhostCounter.config.showMax) GhostCounter.bestiaryCurrentKill.addSeparators() else currentKill.addSeparators(), - ) - .replace("%percentNumber%", percent(GhostCounter.bestiaryCurrentKill.toDouble())) - .replace("%killNeeded%", killNeeded.shortFormat()) - .replace("%currentLevel%", currentLevel) - .replace("%nextLevel%", nextLevel) - .replace("&", "§") - } - - private fun percent(number: Double) = - 100.0.coerceAtMost(((number / 100_000) * 100).roundTo(4)).toString() -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index 2c7d34c0f8bb..d2bbc52f4a04 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -3,26 +3,27 @@ package at.hannibal2.skyhanni.features.combat.ghosttracker import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.data.model.TabWidget import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.ProfileJoinEvent import at.hannibal2.skyhanni.events.PurseChangeCause import at.hannibal2.skyhanni.events.PurseChangeEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.SkillExpGainEvent -import at.hannibal2.skyhanni.events.TabListUpdateEvent +import at.hannibal2.skyhanni.events.WidgetUpdateEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.CollectionUtils.addSearchString import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName -import at.hannibal2.skyhanni.utils.NumberUtil import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatInt -import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary +import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.renderables.Searchable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import at.hannibal2.skyhanni.utils.tracker.ItemTrackerData import at.hannibal2.skyhanni.utils.tracker.SkyHanniItemTracker @@ -34,14 +35,19 @@ object GhostTracker { private val config get() = SkyHanniMod.feature.combat.ghostCounter - val storage = ProfileStorageData.profileSpecific?.ghostStorage + private val storage get() = ProfileStorageData.profileSpecific?.ghostStorage - private var currentBestiaryKills = 0L - private var isMaxBestiary = false + private var currentBestiaryKills: Long + get() = storage?.bestiaryKills ?: 0 + set(value) { + storage?.bestiaryKills = value + } + + private val isMaxBestiary get() = currentBestiaryKills >= MAX_BESTIARY_KILLS private var allowedDrops = listOf() - private val MAX_BESTIARY_KILLS by lazy { getBestiaryKillsUntilLevel(25) } + private val MAX_BESTIARY_KILLS = getBestiaryKillsUntilLevel(25) private val tracker = SkyHanniItemTracker( "Ghost Tracker", @@ -88,7 +94,7 @@ object GhostTracker { override fun getCoinName(item: TrackedItem) = "§6Dropped Coins" override fun getCoinDescription(item: TrackedItem): List { - val coinsFormat = NumberUtil.format(item.totalAmount) + val coinsFormat = item.totalAmount.shortFormat() return listOf( "§7Killing ghosts gives you coins (more with scavenger).", "§7You got §6$coinsFormat coins §7that way." @@ -123,48 +129,35 @@ object GhostTracker { "\\s*Ghost (?\\d+|[XVI]+)(?:§.)*: (?:§.)*MAX" ) + private val SORROW = "SORROW".asInternalName() - private val SORROW by lazy { "SORROW".asInternalName() } - - private fun drawDisplay(data: Data): List> = buildList { + private fun drawDisplay(data: Data): List = buildList { + addSearchString("§e§lGhost Profit Tracker") + val profit = tracker.drawItems(data, { true }, this) config.ghostTrackerText.forEach { line -> - val lines = getLine(line, data) - lines.forEach { add(it) } + addSearchString(getLine(line, data)) } + add(tracker.addTotalProfit(profit, data.kills, "kill")) } - private fun getLine(line: GhostTrackerLines, data: Data): List> { - val itemsList = mutableListOf>() - val profit = tracker.drawItems(data, { true }, itemsList) + private fun getLine(line: GhostTrackerLines, data: Data): String { return when (line) { - GhostTrackerLines.TITLE -> listOf(listOf("§e§lGhost Profit Tracker")) - GhostTrackerLines.ITEMS -> itemsList - GhostTrackerLines.KILLS -> listOf(listOf("§7Kills: §e${data.kills.addSeparators()}")) - GhostTrackerLines.GHOSTS_SINCE_SORROW -> listOf(listOf("§7Ghosts Since Sorrow: §e${data.ghostsSinceSorrow.addSeparators()}")) - GhostTrackerLines.MAX_KILL_COMBO -> listOf(listOf("§7Max Kill Combo: §e${data.maxKillCombo.addSeparators()}")) - GhostTrackerLines.COMBAT_XP_GAINED -> listOf(listOf("§7Combat XP Gained: §e${data.combatXpGained.addSeparators()}")) - GhostTrackerLines.AVERAGE_MAGIC_FIND -> listOf( - listOf( - "§7Average Magic Find: §e${ - getAverageMagicFind( - data.totalMagicFind, - data.totalMagicFindKills - ) - }" - ) - ) - - GhostTrackerLines.BESTIARY_KILLS -> listOf(listOf("§7Bestiary Kills: §e" + if (currentBestiaryKills >= MAX_BESTIARY_KILLS) "MAX" else currentBestiaryKills.addSeparators())) - GhostTrackerLines.TOTAL_PROFIT -> listOf(listOf("§7Total Profit: §6${profit.addSeparators()} coins")) + GhostTrackerLines.KILLS -> "§7Kills: §e${data.kills.addSeparators()}" + GhostTrackerLines.GHOSTS_SINCE_SORROW -> "§7Ghosts Since Sorrow: §e${data.ghostsSinceSorrow.addSeparators()}" + GhostTrackerLines.MAX_KILL_COMBO -> "§7Max Kill Combo: §e${data.maxKillCombo.addSeparators()}" + GhostTrackerLines.COMBAT_XP_GAINED -> "§7Combat XP Gained: §e${data.combatXpGained.addSeparators()}" + GhostTrackerLines.AVERAGE_MAGIC_FIND -> + "§7Average Magic Find: §e${ + getAverageMagicFind( + data.totalMagicFind, + data.totalMagicFindKills + ) + }" + GhostTrackerLines.BESTIARY_KILLS -> "§7Bestiary Kills: §e" + + if (currentBestiaryKills >= MAX_BESTIARY_KILLS) "MAX" else currentBestiaryKills.addSeparators() } } - @SubscribeEvent - fun onProfileJoin(event: ProfileJoinEvent) { - currentBestiaryKills = storage?.bestiaryKills ?: 0 - isMaxBestiary = currentBestiaryKills >= MAX_BESTIARY_KILLS - } - @SubscribeEvent fun onSkillExp(event: SkillExpGainEvent) { if (!isEnabled()) return @@ -179,8 +172,7 @@ object GhostTracker { if (!isEnabled()) return if (event.reason != PurseChangeCause.GAIN_MOB_KILL) return if (event.coins !in 200.0..2_000.0) return - - tracker.addCoins(event.coins.toInt()) + tracker.addCoins(event.coins.toInt(), false) } @SubscribeEvent @@ -191,7 +183,7 @@ object GhostTracker { val mf = group("mf").formatInt() if (!isAllowedItem(internalName)) return - tracker.addItem(internalName, 1) + tracker.addItem(internalName, 1, false) tracker.modify { it.totalMagicFind += mf it.totalMagicFindKills++ @@ -210,21 +202,18 @@ object GhostTracker { return } if (bagOfCashPattern.matches(event.message)) { - tracker.addCoins(1_000_000) + tracker.addCoins(1_000_000, false) return } } @SubscribeEvent - fun onTablistUpdate(event: TabListUpdateEvent) { - if (!isEnabled()) return - if (isMaxBestiary) return - event.tabList.forEach { line -> + fun onWidgetUpdate(event: WidgetUpdateEvent) { + if (!event.isWidget(TabWidget.BESTIARY)) return + if (isMaxBestiary || !isEnabled()) return + event.lines.forEach { line -> bestiaryTablistPattern.matchMatcher(line) { - val level = group("level").romanToDecimalIfNecessary() - val currentLevelKills = group("kills").formatInt().toLong() - - val kills = getTotalBestiaryKills(level, currentLevelKills) + val kills = group("kills").formatInt().toLong() if (kills <= currentBestiaryKills) return val difference = kills - currentBestiaryKills @@ -242,7 +231,6 @@ object GhostTracker { return } if (maxBestiaryTablistPattern.matches(line)) { - isMaxBestiary = true currentBestiaryKills = MAX_BESTIARY_KILLS.toLong() return } @@ -253,7 +241,7 @@ object GhostTracker { fun onRenderOverlay(event: GuiRenderEvent) { if (!isEnabled()) return - tracker.renderDisplay(config.trackerPosition) + tracker.renderDisplay(config.position) } @SubscribeEvent @@ -284,19 +272,12 @@ object GhostTracker { IslandType.DWARVEN_MINES.isInIsland() && LorenzUtils.skyBlockArea == "The Mist" && config.enabled enum class GhostTrackerLines(private val display: String) { - TITLE("§e§lGhost Profit Tracker\""), - ITEMS( - " §723x §9Sorrow§7: §67.47M\n" + - " §713 §9Plasma§7: §6260k\n" + - " §741 §9Volta§7: §6195k\n" - ), KILLS("§7Kills: §e7,813"), GHOSTS_SINCE_SORROW("§7Ghosts Since Sorrow: §e71"), MAX_KILL_COMBO("§7Max Kill Combo: §e681"), COMBAT_XP_GAINED("§7Combat XP Gained: §e4,687,800"), AVERAGE_MAGIC_FIND("§7Average Magic Find: §b278.9"), BESTIARY_KILLS("§7Bestiary Kills: §e 71,893"), - TOTAL_PROFIT("§7Total Profit: §67,928,713 coins"), ; override fun toString(): String { @@ -304,7 +285,9 @@ object GhostTracker { } } - private fun getTotalBestiaryKills(level: Int, kills: Long) = getBestiaryKillsUntilLevel(level) + kills + fun reset() { + tracker.resetCommand() + } private fun getBestiaryKillsUntilLevel(level: Int): Int { var killsUntilLevel = 0 @@ -316,21 +299,19 @@ object GhostTracker { private fun getBestiaryKillsInLevel(level: Int): Int { return when (level) { - in 1..3 -> 5 - 4 -> 10 - 5 -> 25 - 6 -> 50 - 7 -> 100 - in 8..9 -> 150 - 10 -> 250 - 11 -> 750 - 12 -> 1_500 - 13 -> 2_000 - in 14..17 -> 2_500 - 18 -> 3_000 - in 19..20 -> 3_500 - 21 -> 25_000 - in 22..25 -> 50_000 + 1, 2, 3, 4, 5 -> 4 + 6 -> 20 + 7 -> 40 + 8, 9 -> 60 + 10 -> 100 + 11 -> 300 + 12 -> 600 + 13 -> 800 + 14, 15, 16, 17 -> 1_000 + 18 -> 1_200 + 19, 20 -> 1_400 + 21 -> 10_000 + 22, 23, 24, 25 -> 20_000 else -> 0 } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt deleted file mode 100644 index 0ea909851fc2..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/utils/CombatUtils.kt +++ /dev/null @@ -1,125 +0,0 @@ -package at.hannibal2.skyhanni.utils - -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostCounter -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData -import at.hannibal2.skyhanni.mixins.transformers.MixinXPInformation -import io.github.moulberry.notenoughupdates.core.util.lerp.LerpUtils -import io.github.moulberry.notenoughupdates.util.XPInformation - -object CombatUtils { - - private var lastTotalXp = -1f - private val xpGainQueue = mutableListOf() - private var xpGainTimer = 0 - var lastUpdate: Long = -1 - private var skillInfo: XPInformation.SkillInfo? = null - private var skillInfoLast: XPInformation.SkillInfo? = null - private const val SKILL_TYPE = "Combat" - var xpGainHourLast = -1f - var xpGainHour = -1f - var isKilling = false - private var lastTotalKill = -1 - private val killGainQueue = mutableListOf() - var lastKillUpdate: Long = -1 - var killGainHourLast = -1 - var killGainHour = -1 - private var gainTimer = 0 - var _isKilling = false - - private fun getSkillInfo(xpInformation: XPInformation.SkillInfo?): Float { - return try { - val a = xpInformation as? MixinXPInformation - a!!.getTotalXp().toFloat() - } catch (e: Error) { - val xpInfo = xpInformation ?: return -1f - xpInfo.totalXp - } - } - - /** - * Taken from NotEnoughUpdates - */ - fun calculateXP() { - lastUpdate = System.currentTimeMillis() - xpGainHourLast = xpGainHour - skillInfoLast = skillInfo - skillInfo = XPInformation.getInstance().getSkillInfo(SKILL_TYPE) ?: return - val totalXp = getSkillInfo(skillInfo) - if (lastTotalXp > 0) { - val delta: Float = totalXp - lastTotalXp - - when { - delta > 0 && delta < 1000 -> { - xpGainTimer = GhostCounter.config.pauseTimer - xpGainQueue.add(0, delta) - calculateXPHour() - } - - xpGainTimer > 0 -> { - xpGainTimer-- - xpGainQueue.add(0, 0f) - calculateXPHour() - } - - delta <= 0 -> { - isKilling = false - } - } - } - lastTotalXp = totalXp - } - - private fun calculateXPHour() { - while (xpGainQueue.size > 30) { - xpGainQueue.removeLast() - } - var totalGain = 0f - for (f in xpGainQueue) totalGain += f - xpGainHour = totalGain * (60 * 60) / xpGainQueue.size - isKilling = true - } - - fun calculateETA() { - lastKillUpdate = System.currentTimeMillis() - killGainHourLast = killGainHour - - GhostCounter.storage?.bestiaryNextLevel?.toInt()?.let { nextLevel -> - GhostCounter.storage?.bestiaryCurrentKill?.toInt()?.let { kill -> - val sum = GhostData.bestiaryData.filterKeys { it <= nextLevel - 1 }.values.sum() - val cKill = sum + kill - val totalKill = if (GhostCounter.config.showMax) GhostCounter.bestiaryCurrentKill else cKill - - if (lastTotalKill > 0) { - val delta: Int = totalKill - lastTotalKill - if (delta in 1..10 || gainTimer > 0) { - gainTimer = maxOf(gainTimer - 1, 0) - killGainQueue.add(0, delta) - while (killGainQueue.size > 30) { - killGainQueue.removeLast() - } - - val totalGain = killGainQueue.sum() - killGainHour = totalGain * 3600 / killGainQueue.size - _isKilling = true - } else if (delta <= 0) { - _isKilling = false - } - } - lastTotalKill = totalKill - } - } - } - - /** - * Taken from NotEnoughUpdates - */ - fun interp(now: Float, last: Float, lastUpdate: Long): Float { - var interp = now - if (last >= 0 && last != now) { - var factor = (System.currentTimeMillis() - lastUpdate) / 1000f - factor = LerpUtils.clampZeroOne(factor) - interp = last + (now - last) * factor - } - return interp - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt index e30395a004c6..8e0238e76574 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniItemTracker.kt @@ -33,6 +33,10 @@ class SkyHanniItemTracker( val SKYBLOCK_COIN = NEUInternalName.SKYBLOCK_COIN } + fun addCoins(amount: Int, command: Boolean) { + addItem(SKYBLOCK_COIN, amount, command) + } + fun addItem(internalName: NEUInternalName, amount: Int, command: Boolean) { modify { it.addItem(internalName, amount, command) From a405a5f74fa2043815f4cf544b57e80a10c905d7 Mon Sep 17 00:00:00 2001 From: ItsEmpa Date: Wed, 2 Oct 2024 14:53:34 +0200 Subject: [PATCH 08/27] remove hardcoded allowed drops Signed-off-by: ItsEmpa --- .../features/combat/ghosttracker/GhostTracker.kt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index d2bbc52f4a04..df014f606c7b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.features.combat.ghosttracker import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.data.jsonobjects.repo.GhostDrops import at.hannibal2.skyhanni.data.model.TabWidget import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.IslandChangeEvent @@ -246,13 +247,7 @@ object GhostTracker { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - //allowedDrops = event.getConstant("GhostDrops").ghost_drops - allowedDrops = listOf( - SORROW, - "PLASMA".asInternalName(), - "VOLTA".asInternalName(), - "GHOST_BOOTS".asInternalName(), - ) + allowedDrops = event.getConstant("GhostDrops").ghost_drops } @SubscribeEvent From 86b6b8586b288f58d12417cabed0fcdc9041f522 Mon Sep 17 00:00:00 2001 From: Empa Date: Sun, 13 Oct 2024 22:51:02 +0200 Subject: [PATCH 09/27] fix merge --- .../hannibal2/skyhanni/config/commands/Commands.kt | 13 ++++--------- .../features/combat/ghostcounter/GhostCounter.kt | 0 2 files changed, 4 insertions(+), 9 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 89f314135541..a4e697b67a5b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -18,7 +18,7 @@ import at.hannibal2.skyhanni.features.bingo.card.nextstephelper.BingoNextStepHel import at.hannibal2.skyhanni.features.chat.ColorFormattingHelper import at.hannibal2.skyhanni.features.chat.translation.Translator import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil +import at.hannibal2.skyhanni.features.combat.ghosttracker.GhostTracker import at.hannibal2.skyhanni.features.commands.HelpCommand import at.hannibal2.skyhanni.features.commands.PartyChatCommands import at.hannibal2.skyhanni.features.commands.PartyCommands @@ -168,11 +168,6 @@ object Commands { @Suppress("LongMethod") private fun usersNormal(event: RegisterCommandsEvent) { - event.register("shimportghostcounterdata") { - description = "Manually importing the ghost counter data from GhostCounterV3" - category = CommandCategory.USERS_ACTIVE - callback { GhostUtil.importCTGhostCounterData() } - } event.register("shcroptime") { description = "Calculates with your current crop per second speed " + "how long you need to farm a crop to collect this amount of items" @@ -398,10 +393,10 @@ object Commands { } // non trackers - event.register("shresetghostcounter") { - description = "Resets the ghost counter" + event.register("shresetghosttracker") { + description = "Resets the Ghost Profit Tracker" category = CommandCategory.USERS_RESET - callback { GhostUtil.reset() } + callback { GhostTracker.reset() } } event.register("shresetcropspeed") { description = "Resets garden crop speed data and best crop time data" diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt deleted file mode 100644 index e69de29bb2d1..000000000000 From 36b5316dd47e4c88321b6d17a5809314e04b3d58 Mon Sep 17 00:00:00 2001 From: Empa Date: Sat, 19 Oct 2024 09:56:33 +0200 Subject: [PATCH 10/27] use graph area change event for ghost tracker --- .../combat/ghosttracker/GhostTracker.kt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index df014f606c7b..f9ec640de026 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.features.combat.ghosttracker import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.event.HandleEvent import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.jsonobjects.repo.GhostDrops @@ -13,6 +14,7 @@ import at.hannibal2.skyhanni.events.PurseChangeEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent import at.hannibal2.skyhanni.events.SkillExpGainEvent import at.hannibal2.skyhanni.events.WidgetUpdateEvent +import at.hannibal2.skyhanni.events.skyblock.GraphAreaChangeEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.CollectionUtils.addSearchString import at.hannibal2.skyhanni.utils.LorenzUtils @@ -45,11 +47,11 @@ object GhostTracker { } private val isMaxBestiary get() = currentBestiaryKills >= MAX_BESTIARY_KILLS - - private var allowedDrops = listOf() - + private var allowedDrops = setOf() private val MAX_BESTIARY_KILLS = getBestiaryKillsUntilLevel(25) + private var inArea: Boolean = false + private val tracker = SkyHanniItemTracker( "Ghost Tracker", { Data() }, @@ -247,7 +249,12 @@ object GhostTracker { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - allowedDrops = event.getConstant("GhostDrops").ghost_drops + allowedDrops = event.getConstant("GhostDrops").ghost_drops.toSet() + } + + @HandleEvent + fun onAreaChange(event: GraphAreaChangeEvent) { + inArea = event.area == "The Mist" && IslandType.DWARVEN_MINES.isInIsland() } @SubscribeEvent @@ -263,8 +270,7 @@ object GhostTracker { if (mf == 0L || kills == 0L) 0.0 else mf / (kills).toDouble() - private fun isEnabled() = - IslandType.DWARVEN_MINES.isInIsland() && LorenzUtils.skyBlockArea == "The Mist" && config.enabled + private fun isEnabled() = inArea && config.enabled enum class GhostTrackerLines(private val display: String) { KILLS("§7Kills: §e7,813"), From fd5ed0a489d42664ec5b9f36cc1dd070618a6bc0 Mon Sep 17 00:00:00 2001 From: Empa Date: Tue, 22 Oct 2024 12:26:30 +0200 Subject: [PATCH 11/27] serialize ghost drops name --- .../hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.java | 5 +++-- .../skyhanni/features/combat/ghosttracker/GhostTracker.kt | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.java index 79059335a5cf..78bd6ccb7657 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.java +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.java @@ -2,10 +2,11 @@ import at.hannibal2.skyhanni.utils.NEUInternalName; import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; import java.util.List; public class GhostDrops { - @Expose - public List ghost_drops; + @Expose @SerializedName("ghost_drops") + public List ghostDrops; } diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index f9ec640de026..2e4f12801f6d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -249,7 +249,7 @@ object GhostTracker { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - allowedDrops = event.getConstant("GhostDrops").ghost_drops.toSet() + allowedDrops = event.getConstant("GhostDrops").ghostDrops.toSet() } @HandleEvent From bc9b7125975fdbc95a1cd3caa30ef8630ff46754 Mon Sep 17 00:00:00 2001 From: Empa Date: Tue, 22 Oct 2024 14:04:58 +0200 Subject: [PATCH 12/27] i hate detekt grr --- .../skyhanni/features/combat/ghosttracker/GhostTracker.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index 2e4f12801f6d..dd5d535da86c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -55,7 +55,8 @@ object GhostTracker { private val tracker = SkyHanniItemTracker( "Ghost Tracker", { Data() }, - { it.ghostStorage.ghostTracker }) { drawDisplay(it) } + { it.ghostStorage.ghostTracker }, + ) { drawDisplay(it) } class Data : ItemTrackerData() { From f68502be3b07c381a25deb61ad1e4508aa548093 Mon Sep 17 00:00:00 2001 From: Empa Date: Tue, 22 Oct 2024 14:05:51 +0200 Subject: [PATCH 13/27] another fix detekt, awesome! --- .../skyhanni/features/combat/ghosttracker/GhostTracker.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index dd5d535da86c..19a69f724059 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -157,8 +157,8 @@ object GhostTracker { data.totalMagicFindKills ) }" - GhostTrackerLines.BESTIARY_KILLS -> "§7Bestiary Kills: §e" + - if (currentBestiaryKills >= MAX_BESTIARY_KILLS) "MAX" else currentBestiaryKills.addSeparators() + GhostTrackerLines.BESTIARY_KILLS -> + "§7Bestiary Kills: §e" + if (currentBestiaryKills >= MAX_BESTIARY_KILLS) "MAX" else currentBestiaryKills.addSeparators() } } From 04db16c2220c4bc0990fbc2c19073da6dc6e38e7 Mon Sep 17 00:00:00 2001 From: Cal Date: Tue, 22 Oct 2024 23:58:32 +1100 Subject: [PATCH 14/27] Rename .java to .kt --- .../data/jsonobjects/repo/{GhostDrops.java => GhostDrops.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/{GhostDrops.java => GhostDrops.kt} (100%) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.kt similarity index 100% rename from src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.java rename to src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.kt From abceeb0fccd375a2e6f97056b597e831a3cf3672 Mon Sep 17 00:00:00 2001 From: Cal Date: Tue, 22 Oct 2024 23:58:33 +1100 Subject: [PATCH 15/27] update baseline, move command, convert repo file to kotlin --- detekt/baseline.xml | 4 ---- .../skyhanni/config/commands/Commands.kt | 6 ------ .../data/jsonobjects/repo/GhostDrops.kt | 17 +++++++---------- .../combat/ghosttracker/GhostTracker.kt | 11 +++++++++-- versions/1.8.9/detekt/baseline.xml | 4 ---- 5 files changed, 16 insertions(+), 26 deletions(-) diff --git a/detekt/baseline.xml b/detekt/baseline.xml index 338c7d66d3cf..6c4a38b49b55 100644 --- a/detekt/baseline.xml +++ b/detekt/baseline.xml @@ -18,7 +18,6 @@ CyclomaticComplexMethod:GardenBestCropTime.kt$GardenBestCropTime$fun drawBestDisplay(currentCrop: CropType?): List<List<Any>> CyclomaticComplexMethod:GardenCropMilestoneDisplay.kt$GardenCropMilestoneDisplay$private fun drawProgressDisplay(crop: CropType): List<Renderable> CyclomaticComplexMethod:GardenVisitorFeatures.kt$GardenVisitorFeatures$private fun readToolTip(visitor: VisitorAPI.Visitor, itemStack: ItemStack?, toolTip: MutableList<String>) - CyclomaticComplexMethod:GhostCounter.kt$GhostCounter$private fun drawDisplay() CyclomaticComplexMethod:GraphEditor.kt$GraphEditor$private fun input() CyclomaticComplexMethod:ItemDisplayOverlayFeatures.kt$ItemDisplayOverlayFeatures$private fun getStackTip(item: ItemStack): String? CyclomaticComplexMethod:ItemNameResolver.kt$ItemNameResolver$internal fun getInternalNameOrNull(itemName: String): NEUInternalName? @@ -36,7 +35,6 @@ InjectDispatcher:MayorAPI.kt$MayorAPI$IO LongMethod:CopyNearbyEntitiesCommand.kt$CopyNearbyEntitiesCommand$fun command(args: Array<String>) LongMethod:CropMoneyDisplay.kt$CropMoneyDisplay$private fun drawDisplay(): List<List<Any>> - LongMethod:GhostCounter.kt$GhostCounter$private fun drawDisplay() LongMethod:GraphEditor.kt$GraphEditor$private fun input() LongMethod:ItemDisplayOverlayFeatures.kt$ItemDisplayOverlayFeatures$private fun getStackTip(item: ItemStack): String? LongMethod:MinecraftConsoleFilter.kt$MinecraftConsoleFilter$override fun filter(event: LogEvent?): Filter.Result @@ -187,7 +185,6 @@ UnsafeCallOnNullableType:GardenCropMilestoneDisplay.kt$GardenCropMilestoneDisplay$cultivatingData[crop]!! UnsafeCallOnNullableType:GardenCropMilestonesCommunityFix.kt$GardenCropMilestonesCommunityFix$map[crop]!! UnsafeCallOnNullableType:GardenPlotIcon.kt$GardenPlotIcon$originalStack[index]!! - UnsafeCallOnNullableType:GhostCounter.kt$GhostCounter$storage?.totalMF!! UnsafeCallOnNullableType:Graph.kt$Graph.Companion$position!! UnsafeCallOnNullableType:Graph.kt$distances.distances[end]!! UnsafeCallOnNullableType:GriffinBurrowHelper.kt$GriffinBurrowHelper$particleBurrows[targetLocation]!! @@ -270,7 +267,6 @@ VarCouldBeVal:GardenPlotIcon.kt$GardenPlotIcon$private var originalStack = mutableMapOf<Int, ItemStack>() VarCouldBeVal:GardenPlotMenuHighlighting.kt$GardenPlotMenuHighlighting$private var highlightedPlots = mutableMapOf<GardenPlotAPI.Plot, PlotStatusType>() VarCouldBeVal:GardenVisitorColorNames.kt$GardenVisitorColorNames$private var visitorColors = mutableMapOf<String, String>() // name -> color code - VarCouldBeVal:GhostData.kt$GhostData$private var session = mutableMapOf( Option.KILLS to 0.0, Option.SORROWCOUNT to 0.0, Option.VOLTACOUNT to 0.0, Option.PLASMACOUNT to 0.0, Option.GHOSTLYBOOTS to 0.0, Option.BAGOFCASH to 0.0, Option.TOTALDROPS to 0.0, Option.SCAVENGERCOINS to 0.0, Option.MAXKILLCOMBO to 0.0, Option.SKILLXPGAINED to 0.0 ) VarCouldBeVal:GraphEditor.kt$GraphEditor$var vector = LocationUtils.calculatePlayerFacingDirection() VarCouldBeVal:HoppityCollectionStats.kt$HoppityCollectionStats$private var highlightMap = mutableMapOf<String, LorenzColor>() VarCouldBeVal:HoppityEggLocations.kt$HoppityEggLocations$// TODO add gui/command to show total data/missing islands private var collectedEggStorage: MutableMap<IslandType, MutableSet<LorenzVec>> get() = ChocolateFactoryAPI.profileStorage?.collectedEggLocations ?: mutableMapOf() set(value) { ChocolateFactoryAPI.profileStorage?.collectedEggLocations = value } diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 044d0e9f3150..7df0063b853b 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -18,7 +18,6 @@ import at.hannibal2.skyhanni.features.bingo.card.nextstephelper.BingoNextStepHel import at.hannibal2.skyhanni.features.chat.ColorFormattingHelper import at.hannibal2.skyhanni.features.chat.translation.Translator import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker -import at.hannibal2.skyhanni.features.combat.ghosttracker.GhostTracker import at.hannibal2.skyhanni.features.commands.HelpCommand import at.hannibal2.skyhanni.features.commands.PartyChatCommands import at.hannibal2.skyhanni.features.commands.PartyCommands @@ -395,11 +394,6 @@ object Commands { } // non trackers - event.register("shresetghosttracker") { - description = "Resets the Ghost Profit Tracker" - category = CommandCategory.USERS_RESET - callback { GhostTracker.reset() } - } event.register("shresetcropspeed") { description = "Resets garden crop speed data and best crop time data" category = CommandCategory.USERS_RESET diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.kt index 78bd6ccb7657..0a3bcaaf829d 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.kt @@ -1,12 +1,9 @@ -package at.hannibal2.skyhanni.data.jsonobjects.repo; +package at.hannibal2.skyhanni.data.jsonobjects.repo -import at.hannibal2.skyhanni.utils.NEUInternalName; -import com.google.gson.annotations.Expose; -import com.google.gson.annotations.SerializedName; +import at.hannibal2.skyhanni.utils.NEUInternalName +import com.google.gson.annotations.Expose +import com.google.gson.annotations.SerializedName -import java.util.List; - -public class GhostDrops { - @Expose @SerializedName("ghost_drops") - public List ghostDrops; -} +data class GhostDrops( + @Expose @SerializedName("ghost_drops") val ghostDrops: List, +) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index 19a69f724059..a49157539b5b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -2,6 +2,8 @@ package at.hannibal2.skyhanni.features.combat.ghosttracker import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.config.commands.CommandCategory +import at.hannibal2.skyhanni.config.commands.CommandRegistrationEvent import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.jsonobjects.repo.GhostDrops @@ -287,8 +289,13 @@ object GhostTracker { } } - fun reset() { - tracker.resetCommand() + @HandleEvent + fun onCommandRegistration(event: CommandRegistrationEvent) { + event.register("shresetghosttracker") { + description = "Resets the Ghost Profit Tracker" + category = CommandCategory.USERS_RESET + callback { tracker.resetCommand() } + } } private fun getBestiaryKillsUntilLevel(level: Int): Int { diff --git a/versions/1.8.9/detekt/baseline.xml b/versions/1.8.9/detekt/baseline.xml index 338c7d66d3cf..6c4a38b49b55 100644 --- a/versions/1.8.9/detekt/baseline.xml +++ b/versions/1.8.9/detekt/baseline.xml @@ -18,7 +18,6 @@ CyclomaticComplexMethod:GardenBestCropTime.kt$GardenBestCropTime$fun drawBestDisplay(currentCrop: CropType?): List<List<Any>> CyclomaticComplexMethod:GardenCropMilestoneDisplay.kt$GardenCropMilestoneDisplay$private fun drawProgressDisplay(crop: CropType): List<Renderable> CyclomaticComplexMethod:GardenVisitorFeatures.kt$GardenVisitorFeatures$private fun readToolTip(visitor: VisitorAPI.Visitor, itemStack: ItemStack?, toolTip: MutableList<String>) - CyclomaticComplexMethod:GhostCounter.kt$GhostCounter$private fun drawDisplay() CyclomaticComplexMethod:GraphEditor.kt$GraphEditor$private fun input() CyclomaticComplexMethod:ItemDisplayOverlayFeatures.kt$ItemDisplayOverlayFeatures$private fun getStackTip(item: ItemStack): String? CyclomaticComplexMethod:ItemNameResolver.kt$ItemNameResolver$internal fun getInternalNameOrNull(itemName: String): NEUInternalName? @@ -36,7 +35,6 @@ InjectDispatcher:MayorAPI.kt$MayorAPI$IO LongMethod:CopyNearbyEntitiesCommand.kt$CopyNearbyEntitiesCommand$fun command(args: Array<String>) LongMethod:CropMoneyDisplay.kt$CropMoneyDisplay$private fun drawDisplay(): List<List<Any>> - LongMethod:GhostCounter.kt$GhostCounter$private fun drawDisplay() LongMethod:GraphEditor.kt$GraphEditor$private fun input() LongMethod:ItemDisplayOverlayFeatures.kt$ItemDisplayOverlayFeatures$private fun getStackTip(item: ItemStack): String? LongMethod:MinecraftConsoleFilter.kt$MinecraftConsoleFilter$override fun filter(event: LogEvent?): Filter.Result @@ -187,7 +185,6 @@ UnsafeCallOnNullableType:GardenCropMilestoneDisplay.kt$GardenCropMilestoneDisplay$cultivatingData[crop]!! UnsafeCallOnNullableType:GardenCropMilestonesCommunityFix.kt$GardenCropMilestonesCommunityFix$map[crop]!! UnsafeCallOnNullableType:GardenPlotIcon.kt$GardenPlotIcon$originalStack[index]!! - UnsafeCallOnNullableType:GhostCounter.kt$GhostCounter$storage?.totalMF!! UnsafeCallOnNullableType:Graph.kt$Graph.Companion$position!! UnsafeCallOnNullableType:Graph.kt$distances.distances[end]!! UnsafeCallOnNullableType:GriffinBurrowHelper.kt$GriffinBurrowHelper$particleBurrows[targetLocation]!! @@ -270,7 +267,6 @@ VarCouldBeVal:GardenPlotIcon.kt$GardenPlotIcon$private var originalStack = mutableMapOf<Int, ItemStack>() VarCouldBeVal:GardenPlotMenuHighlighting.kt$GardenPlotMenuHighlighting$private var highlightedPlots = mutableMapOf<GardenPlotAPI.Plot, PlotStatusType>() VarCouldBeVal:GardenVisitorColorNames.kt$GardenVisitorColorNames$private var visitorColors = mutableMapOf<String, String>() // name -> color code - VarCouldBeVal:GhostData.kt$GhostData$private var session = mutableMapOf( Option.KILLS to 0.0, Option.SORROWCOUNT to 0.0, Option.VOLTACOUNT to 0.0, Option.PLASMACOUNT to 0.0, Option.GHOSTLYBOOTS to 0.0, Option.BAGOFCASH to 0.0, Option.TOTALDROPS to 0.0, Option.SCAVENGERCOINS to 0.0, Option.MAXKILLCOMBO to 0.0, Option.SKILLXPGAINED to 0.0 ) VarCouldBeVal:GraphEditor.kt$GraphEditor$var vector = LocationUtils.calculatePlayerFacingDirection() VarCouldBeVal:HoppityCollectionStats.kt$HoppityCollectionStats$private var highlightMap = mutableMapOf<String, LorenzColor>() VarCouldBeVal:HoppityEggLocations.kt$HoppityEggLocations$// TODO add gui/command to show total data/missing islands private var collectedEggStorage: MutableMap<IslandType, MutableSet<LorenzVec>> get() = ChocolateFactoryAPI.profileStorage?.collectedEggLocations ?: mutableMapOf() set(value) { ChocolateFactoryAPI.profileStorage?.collectedEggLocations = value } From a050ac6a58c433fbe13bedf15ccf7f48b847b5d9 Mon Sep 17 00:00:00 2001 From: Cal Date: Wed, 23 Oct 2024 00:15:21 +1100 Subject: [PATCH 16/27] bye bye neu import --- .../mixins/transformers/MixinXPInformation.java | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinXPInformation.java diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinXPInformation.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinXPInformation.java deleted file mode 100644 index 16fb774cd08e..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/MixinXPInformation.java +++ /dev/null @@ -1,14 +0,0 @@ -package at.hannibal2.skyhanni.mixins.transformers; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Pseudo -@Mixin(targets = "io.github.moulberry.notenoughupdates.util.XPInformation$SkillInfo") -public interface MixinXPInformation { - - @Accessor(value = "totalXp") - double getTotalXp(); - -} From 9985e965ba26eb6f043d7c0c8733e54ee770f3e6 Mon Sep 17 00:00:00 2001 From: Cal Date: Wed, 23 Oct 2024 01:20:12 +1100 Subject: [PATCH 17/27] should work :pray: --- .../skyhanni/config/ConfigUpdaterMigrator.kt | 2 +- .../storage/ProfileSpecificStorage.java | 32 +----------- .../features/combat/ghostcounter/GhostData.kt | 20 -------- .../combat/ghosttracker/GhostTracker.kt | 51 ++++++++++++++++--- 4 files changed, 45 insertions(+), 60 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostData.kt diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index f8afe645cf85..d90ce7730e61 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt @@ -12,7 +12,7 @@ import com.google.gson.JsonPrimitive object ConfigUpdaterMigrator { val logger = LorenzLogger("ConfigMigration") - const val CONFIG_VERSION = 63 + const val CONFIG_VERSION = 64 fun JsonElement.at(chain: List, init: Boolean): JsonElement? { if (chain.isEmpty()) return this if (this !is JsonObject) return null diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java index 0e39bd053d39..6004ae04e34f 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java @@ -8,7 +8,6 @@ import at.hannibal2.skyhanni.data.model.ComposterUpgrade; import at.hannibal2.skyhanni.data.model.SkyblockStat; import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker; -import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData; import at.hannibal2.skyhanni.features.combat.ghosttracker.GhostTracker; import at.hannibal2.skyhanni.features.dungeon.CroesusChestTracker; import at.hannibal2.skyhanni.features.dungeon.DungeonFloor; @@ -207,7 +206,7 @@ public static class CarnivalStorage { } @Expose - public Map stats = new HashMap<>(SkyblockStat.getEntries().size()); + public Map stats = new HashMap<>(SkyblockStat.getEntries().size()); @Expose public MaxwellPowerStorage maxwell = new MaxwellPowerStorage(); @@ -490,35 +489,6 @@ public static class FarmingWeightConfig { public VinylType activeVinyl = null; } - // TODO: Merge data with GhostProfitTracker at a later date - @Expose - public GhostCounter ghostCounter = new GhostCounter(); - - public static class GhostCounter { - - @Expose - public Map data = new HashMap<>(); - - @Expose - public boolean ctDataImported = false; - - @Expose - public double bestiaryNextLevel = 0; - - @Expose - public double bestiaryCurrentKill = 0; - - @Expose - public double bestiaryKillNeeded = 0; - - @Expose - public double totalMF = 0; - - @Expose - public int configUpdateVersion = 0; - - } - @Expose public GhostStorage ghostStorage = new GhostStorage(); diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostData.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostData.kt deleted file mode 100644 index 18fffae12547..000000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostData.kt +++ /dev/null @@ -1,20 +0,0 @@ -package at.hannibal2.skyhanni.features.combat.ghostcounter - -object GhostData { - - enum class Option { - KILLS, - SORROWCOUNT, - VOLTACOUNT, - PLASMACOUNT, - GHOSTLYBOOTS, - BAGOFCASH, - KILLCOMBOCOINS, - TOTALDROPS, - GHOSTSINCESORROW, - SCAVENGERCOINS, - MAXKILLCOMBO, - KILLCOMBO, - SKILLXPGAINED, - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index a49157539b5b..31a1e1f7d999 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.combat.ghosttracker import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.event.HandleEvent +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.commands.CommandCategory import at.hannibal2.skyhanni.config.commands.CommandRegistrationEvent import at.hannibal2.skyhanni.data.IslandType @@ -32,6 +33,8 @@ import at.hannibal2.skyhanni.utils.renderables.Searchable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import at.hannibal2.skyhanni.utils.tracker.ItemTrackerData import at.hannibal2.skyhanni.utils.tracker.SkyHanniItemTracker +import com.google.gson.JsonElement +import com.google.gson.JsonObject import com.google.gson.annotations.Expose import net.minecraftforge.fml.common.eventhandler.SubscribeEvent @@ -93,7 +96,7 @@ object GhostTracker { return listOf( "§7Dropped §e${timesGained.addSeparators()} §7times.", - "§7Your drop chance per kill: §c$perKill" + "§7Your drop chance per kill: §c$perKill", ) } @@ -103,7 +106,7 @@ object GhostTracker { val coinsFormat = item.totalAmount.shortFormat() return listOf( "§7Killing ghosts gives you coins (more with scavenger).", - "§7You got §6$coinsFormat coins §7that way." + "§7You got §6$coinsFormat coins §7that way.", ) } } @@ -112,15 +115,15 @@ object GhostTracker { private val itemDropPattern by patternGroup.pattern( "itemdrop", - "§6§lRARE DROP! §r§9(?[^§]*) §r§b\\([+](?:§.)*(?\\d*)% §r§b✯ Magic Find§r§b\\)" + "§6§lRARE DROP! §r§9(?[^§]*) §r§b\\([+](?:§.)*(?\\d*)% §r§b✯ Magic Find§r§b\\)", ) private val killComboEndPattern by patternGroup.pattern( "killcombo.end", - "§cYour Kill Combo has expired! You reached a (?\\d+) Kill Combo!" + "§cYour Kill Combo has expired! You reached a (?\\d+) Kill Combo!", ) private val bagOfCashPattern by patternGroup.pattern( "bagofcash", - "§eThe ghost's death materialized §r§61,000,000 coins §r§efrom the mists!" + "§eThe ghost's death materialized §r§61,000,000 coins §r§efrom the mists!", ) /** @@ -128,11 +131,11 @@ object GhostTracker { */ private val bestiaryTablistPattern by patternGroup.pattern( "tablist.bestiary", - "\\s*Ghost (?\\d+|[XVI]+)(?:§.)*: (?:§.)*(?[\\d,.]+)/(?[\\d,.]+)" + "\\s*Ghost (?\\d+|[XVI]+)(?:§.)*: (?:§.)*(?[\\d,.]+)/(?[\\d,.]+)", ) private val maxBestiaryTablistPattern by patternGroup.pattern( "tablist.bestiarymax", - "\\s*Ghost (?\\d+|[XVI]+)(?:§.)*: (?:§.)*MAX" + "\\s*Ghost (?\\d+|[XVI]+)(?:§.)*: (?:§.)*MAX", ) private val SORROW = "SORROW".asInternalName() @@ -156,9 +159,10 @@ object GhostTracker { "§7Average Magic Find: §e${ getAverageMagicFind( data.totalMagicFind, - data.totalMagicFindKills + data.totalMagicFindKills, ) }" + GhostTrackerLines.BESTIARY_KILLS -> "§7Bestiary Kills: §e" + if (currentBestiaryKills >= MAX_BESTIARY_KILLS) "MAX" else currentBestiaryKills.addSeparators() } @@ -298,6 +302,7 @@ object GhostTracker { } } + // TODO: In the future move to a utils class and use neu bestiary data private fun getBestiaryKillsUntilLevel(level: Int): Int { var killsUntilLevel = 0 for (i in 1..level) { @@ -324,4 +329,34 @@ object GhostTracker { else -> 0 } } + + @SubscribeEvent + fun onConfigUpdaterMigratorConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(64, "#profile.ghostCounter.data.KILLS", "#profile.ghostStorage.ghostTracker.kills") + event.move(64, "#profile.ghostCounter.data.GHOSTSINCESORROW", "#profile.ghostStorage.ghostTracker.ghostsSinceSorrow") + event.move(64, "#profile.ghostCounter.data.MAXKILLCOMBO", "#profile.ghostStorage.ghostTracker.maxKillCombo") + event.move(64, "#profile.ghostCounter.data.SKILLXPGAINED", "#profile.ghostStorage.ghostTracker.combatXpGained") + + event.move(64, "#profile.ghostCounter.data.SORROWCOUNT", "#profile.ghostStorage.ghostTracker.items.SORROW") { + element -> migrateItem(element) + } + event.move(64, "#profile.ghostCounter.data.PLASMACOUNT", "#profile.ghostStorage.ghostTracker.items.PLASMA") { + element -> migrateItem(element) + } + event.move(64, "#profile.ghostCounter.data.VOLTACOUNT", "#profile.ghostStorage.ghostTracker.items.VOLTA") { + element -> migrateItem(element) + } + event.move(64, "#profile.ghostCounter.data.GHOSTLYBOOTS", "#profile.ghostStorage.ghostTracker.items.GHOST_BOOTS") { + element -> migrateItem(element) + } + } + + private fun migrateItem(oldData: JsonElement): JsonElement { + val oldAmount = oldData.asInt + val newData = JsonObject() + newData.addProperty("timesGained", oldAmount) + newData.addProperty("totalAmount", oldAmount) + newData.addProperty("hidden", false) + return newData + } } From d675489d9a7eaf9a929d626676c93e42070d91c3 Mon Sep 17 00:00:00 2001 From: Cal Date: Wed, 23 Oct 2024 01:37:13 +1100 Subject: [PATCH 18/27] make detekt happy and move over total magic find --- .../features/combat/ghosttracker/GhostTracker.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index 31a1e1f7d999..93e3281a23e8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -336,18 +336,19 @@ object GhostTracker { event.move(64, "#profile.ghostCounter.data.GHOSTSINCESORROW", "#profile.ghostStorage.ghostTracker.ghostsSinceSorrow") event.move(64, "#profile.ghostCounter.data.MAXKILLCOMBO", "#profile.ghostStorage.ghostTracker.maxKillCombo") event.move(64, "#profile.ghostCounter.data.SKILLXPGAINED", "#profile.ghostStorage.ghostTracker.combatXpGained") + event.move(64, "#profile.ghostCounter.totalMF", "#profile.ghostStorage.ghostTracker.totalMagicFind") event.move(64, "#profile.ghostCounter.data.SORROWCOUNT", "#profile.ghostStorage.ghostTracker.items.SORROW") { - element -> migrateItem(element) + migrateItem(it) } event.move(64, "#profile.ghostCounter.data.PLASMACOUNT", "#profile.ghostStorage.ghostTracker.items.PLASMA") { - element -> migrateItem(element) + migrateItem(it) } event.move(64, "#profile.ghostCounter.data.VOLTACOUNT", "#profile.ghostStorage.ghostTracker.items.VOLTA") { - element -> migrateItem(element) + migrateItem(it) } event.move(64, "#profile.ghostCounter.data.GHOSTLYBOOTS", "#profile.ghostStorage.ghostTracker.items.GHOST_BOOTS") { - element -> migrateItem(element) + migrateItem(it) } } From 368a681a206af0bb29390428ccdcdc97a999a4b1 Mon Sep 17 00:00:00 2001 From: Empa Date: Tue, 22 Oct 2024 23:00:13 +0200 Subject: [PATCH 19/27] make migrateItem a local function --- .../combat/ghosttracker/GhostTracker.kt | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index 93e3281a23e8..28c5b8e29127 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -332,32 +332,25 @@ object GhostTracker { @SubscribeEvent fun onConfigUpdaterMigratorConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + + fun migrateItem(oldData: JsonElement): JsonElement { + val oldAmount = oldData.asInt + val newData = JsonObject() + newData.addProperty("timesGained", oldAmount) + newData.addProperty("totalAmount", oldAmount) + newData.addProperty("hidden", false) + return newData + } + event.move(64, "#profile.ghostCounter.data.KILLS", "#profile.ghostStorage.ghostTracker.kills") event.move(64, "#profile.ghostCounter.data.GHOSTSINCESORROW", "#profile.ghostStorage.ghostTracker.ghostsSinceSorrow") event.move(64, "#profile.ghostCounter.data.MAXKILLCOMBO", "#profile.ghostStorage.ghostTracker.maxKillCombo") event.move(64, "#profile.ghostCounter.data.SKILLXPGAINED", "#profile.ghostStorage.ghostTracker.combatXpGained") event.move(64, "#profile.ghostCounter.totalMF", "#profile.ghostStorage.ghostTracker.totalMagicFind") - event.move(64, "#profile.ghostCounter.data.SORROWCOUNT", "#profile.ghostStorage.ghostTracker.items.SORROW") { - migrateItem(it) - } - event.move(64, "#profile.ghostCounter.data.PLASMACOUNT", "#profile.ghostStorage.ghostTracker.items.PLASMA") { - migrateItem(it) - } - event.move(64, "#profile.ghostCounter.data.VOLTACOUNT", "#profile.ghostStorage.ghostTracker.items.VOLTA") { - migrateItem(it) - } - event.move(64, "#profile.ghostCounter.data.GHOSTLYBOOTS", "#profile.ghostStorage.ghostTracker.items.GHOST_BOOTS") { - migrateItem(it) - } - } - - private fun migrateItem(oldData: JsonElement): JsonElement { - val oldAmount = oldData.asInt - val newData = JsonObject() - newData.addProperty("timesGained", oldAmount) - newData.addProperty("totalAmount", oldAmount) - newData.addProperty("hidden", false) - return newData + event.move(64, "#profile.ghostCounter.data.SORROWCOUNT", "#profile.ghostStorage.ghostTracker.items.SORROW", ::migrateItem) + event.move(64, "#profile.ghostCounter.data.PLASMACOUNT", "#profile.ghostStorage.ghostTracker.items.PLASMA", ::migrateItem) + event.move(64, "#profile.ghostCounter.data.VOLTACOUNT", "#profile.ghostStorage.ghostTracker.items.VOLTA", ::migrateItem) + event.move(64, "#profile.ghostCounter.data.GHOSTLYBOOTS", "#profile.ghostStorage.ghostTracker.items.GHOST_BOOTS", ::migrateItem) } } From 498a7efdfb11f2e19732d37b70a61a85a7317b0e Mon Sep 17 00:00:00 2001 From: Cal Date: Wed, 23 Oct 2024 18:23:01 +1100 Subject: [PATCH 20/27] finish migrating --- detekt/baseline.xml | 1 - .../config/storage/ProfileSpecificStorage.java | 3 +++ .../combat/ghosttracker/GhostTracker.kt | 17 ++++++++++++++++- versions/1.8.9/detekt/baseline.xml | 1 - 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/detekt/baseline.xml b/detekt/baseline.xml index 6c4a38b49b55..df651f678ce2 100644 --- a/detekt/baseline.xml +++ b/detekt/baseline.xml @@ -150,7 +150,6 @@ UnsafeCallOnNullableType:CollectionUtils.kt$CollectionUtils$this.merge(key, number, Float::plus)!! UnsafeCallOnNullableType:CollectionUtils.kt$CollectionUtils$this.merge(key, number, Int::plus)!! UnsafeCallOnNullableType:CollectionUtils.kt$CollectionUtils$this.merge(key, number, Long::plus)!! - UnsafeCallOnNullableType:CombatUtils.kt$CombatUtils$a!! UnsafeCallOnNullableType:CompactBestiaryChatMessage.kt$CompactBestiaryChatMessage$it.groups[1]!! UnsafeCallOnNullableType:ConfigManager.kt$ConfigManager$file!! UnsafeCallOnNullableType:CorpseTracker.kt$CorpseTracker$applicableKeys.first().key!! diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java index 6004ae04e34f..ad8481e86c73 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java @@ -499,6 +499,9 @@ public static class GhostStorage { @Expose public Long bestiaryKills = 0L; + + @Expose + public boolean migratedTotalKills = false; } @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index 28c5b8e29127..7891ebc9f672 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ProfileStorageData import at.hannibal2.skyhanni.data.jsonobjects.repo.GhostDrops import at.hannibal2.skyhanni.data.model.TabWidget +import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent import at.hannibal2.skyhanni.events.IslandChangeEvent import at.hannibal2.skyhanni.events.LorenzChatEvent @@ -293,6 +294,20 @@ object GhostTracker { } } + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + val storage = storage ?: return + if (storage.migratedTotalKills) return + tracker.modify { + var count = 0L + it.items.forEach { (_, item) -> + count += item.timesGained.toInt() + } + it.totalMagicFindKills = count + } + storage.migratedTotalKills = true + } + @HandleEvent fun onCommandRegistration(event: CommandRegistrationEvent) { event.register("shresetghosttracker") { @@ -331,7 +346,7 @@ object GhostTracker { } @SubscribeEvent - fun onConfigUpdaterMigratorConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { fun migrateItem(oldData: JsonElement): JsonElement { val oldAmount = oldData.asInt diff --git a/versions/1.8.9/detekt/baseline.xml b/versions/1.8.9/detekt/baseline.xml index 6c4a38b49b55..df651f678ce2 100644 --- a/versions/1.8.9/detekt/baseline.xml +++ b/versions/1.8.9/detekt/baseline.xml @@ -150,7 +150,6 @@ UnsafeCallOnNullableType:CollectionUtils.kt$CollectionUtils$this.merge(key, number, Float::plus)!! UnsafeCallOnNullableType:CollectionUtils.kt$CollectionUtils$this.merge(key, number, Int::plus)!! UnsafeCallOnNullableType:CollectionUtils.kt$CollectionUtils$this.merge(key, number, Long::plus)!! - UnsafeCallOnNullableType:CombatUtils.kt$CombatUtils$a!! UnsafeCallOnNullableType:CompactBestiaryChatMessage.kt$CompactBestiaryChatMessage$it.groups[1]!! UnsafeCallOnNullableType:ConfigManager.kt$ConfigManager$file!! UnsafeCallOnNullableType:CorpseTracker.kt$CorpseTracker$applicableKeys.first().key!! From 5f7c7f0ba3a3086580eb873bfaadc1111046dc44 Mon Sep 17 00:00:00 2001 From: Empa Date: Fri, 25 Oct 2024 10:06:38 +0200 Subject: [PATCH 21/27] add regex tests and change ghost drops constant to set instead of list --- .../skyhanni/data/jsonobjects/repo/GhostDrops.kt | 2 +- .../features/combat/ghosttracker/GhostTracker.kt | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.kt index 0a3bcaaf829d..86ad90b45e24 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.kt @@ -5,5 +5,5 @@ import com.google.gson.annotations.Expose import com.google.gson.annotations.SerializedName data class GhostDrops( - @Expose @SerializedName("ghost_drops") val ghostDrops: List, + @Expose @SerializedName("ghost_drops") val ghostDrops: Set, ) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index 28c5b8e29127..b7bcff53af86 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -113,10 +113,17 @@ object GhostTracker { private val patternGroup = RepoPattern.group("combat.ghosttracker") + /** + * REGEX-TEST: §5§l+20 Kill Combo §r§8§r§3+15☯ Combat Wisdom + */ private val itemDropPattern by patternGroup.pattern( "itemdrop", "§6§lRARE DROP! §r§9(?[^§]*) §r§b\\([+](?:§.)*(?\\d*)% §r§b✯ Magic Find§r§b\\)", ) + + /** + * REGEX-TEST: §cYour Kill Combo has expired! You reached a 32 Kill Combo! + */ private val killComboEndPattern by patternGroup.pattern( "killcombo.end", "§cYour Kill Combo has expired! You reached a (?\\d+) Kill Combo!", @@ -133,6 +140,10 @@ object GhostTracker { "tablist.bestiary", "\\s*Ghost (?\\d+|[XVI]+)(?:§.)*: (?:§.)*(?[\\d,.]+)/(?[\\d,.]+)", ) + + /** + * REGEX-TEST: Ghost 25§r§f: §r§b§lMAX + */ private val maxBestiaryTablistPattern by patternGroup.pattern( "tablist.bestiarymax", "\\s*Ghost (?\\d+|[XVI]+)(?:§.)*: (?:§.)*MAX", @@ -256,7 +267,7 @@ object GhostTracker { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - allowedDrops = event.getConstant("GhostDrops").ghostDrops.toSet() + allowedDrops = event.getConstant("GhostDrops").ghostDrops } @HandleEvent From d32dd2594da653e02ca2dd98d68cfddff646ae17 Mon Sep 17 00:00:00 2001 From: Cal Date: Sat, 16 Nov 2024 18:21:12 +1100 Subject: [PATCH 22/27] config version --- .../skyhanni/config/ConfigUpdaterMigrator.kt | 2 +- .../combat/ghosttracker/GhostTracker.kt | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index dc363f09413a..257518074b06 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt @@ -12,7 +12,7 @@ import com.google.gson.JsonPrimitive object ConfigUpdaterMigrator { val logger = LorenzLogger("ConfigMigration") - const val CONFIG_VERSION = 66 + const val CONFIG_VERSION = 67 fun JsonElement.at(chain: List, init: Boolean): JsonElement? { if (chain.isEmpty()) return this if (this !is JsonObject) return null diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index 91b266115be6..30a21c48e5dd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -368,15 +368,15 @@ object GhostTracker { return newData } - event.move(66, "#profile.ghostCounter.data.KILLS", "#profile.ghostStorage.ghostTracker.kills") - event.move(66, "#profile.ghostCounter.data.GHOSTSINCESORROW", "#profile.ghostStorage.ghostTracker.ghostsSinceSorrow") - event.move(66, "#profile.ghostCounter.data.MAXKILLCOMBO", "#profile.ghostStorage.ghostTracker.maxKillCombo") - event.move(66, "#profile.ghostCounter.data.SKILLXPGAINED", "#profile.ghostStorage.ghostTracker.combatXpGained") - event.move(66, "#profile.ghostCounter.totalMF", "#profile.ghostStorage.ghostTracker.totalMagicFind") - - event.move(66, "#profile.ghostCounter.data.SORROWCOUNT", "#profile.ghostStorage.ghostTracker.items.SORROW", ::migrateItem) - event.move(66, "#profile.ghostCounter.data.PLASMACOUNT", "#profile.ghostStorage.ghostTracker.items.PLASMA", ::migrateItem) - event.move(66, "#profile.ghostCounter.data.VOLTACOUNT", "#profile.ghostStorage.ghostTracker.items.VOLTA", ::migrateItem) - event.move(66, "#profile.ghostCounter.data.GHOSTLYBOOTS", "#profile.ghostStorage.ghostTracker.items.GHOST_BOOTS", ::migrateItem) + event.move(67, "#profile.ghostCounter.data.KILLS", "#profile.ghostStorage.ghostTracker.kills") + event.move(67, "#profile.ghostCounter.data.GHOSTSINCESORROW", "#profile.ghostStorage.ghostTracker.ghostsSinceSorrow") + event.move(67, "#profile.ghostCounter.data.MAXKILLCOMBO", "#profile.ghostStorage.ghostTracker.maxKillCombo") + event.move(67, "#profile.ghostCounter.data.SKILLXPGAINED", "#profile.ghostStorage.ghostTracker.combatXpGained") + event.move(67, "#profile.ghostCounter.totalMF", "#profile.ghostStorage.ghostTracker.totalMagicFind") + + event.move(67, "#profile.ghostCounter.data.SORROWCOUNT", "#profile.ghostStorage.ghostTracker.items.SORROW", ::migrateItem) + event.move(67, "#profile.ghostCounter.data.PLASMACOUNT", "#profile.ghostStorage.ghostTracker.items.PLASMA", ::migrateItem) + event.move(67, "#profile.ghostCounter.data.VOLTACOUNT", "#profile.ghostStorage.ghostTracker.items.VOLTA", ::migrateItem) + event.move(67, "#profile.ghostCounter.data.GHOSTLYBOOTS", "#profile.ghostStorage.ghostTracker.items.GHOST_BOOTS", ::migrateItem) } } From f7fed81f108d6cf6f0bd60686f713a7a58c74d7b Mon Sep 17 00:00:00 2001 From: Cal Date: Sat, 16 Nov 2024 18:33:53 +1100 Subject: [PATCH 23/27] fix regex test --- .../skyhanni/features/combat/ghosttracker/GhostTracker.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index 30a21c48e5dd..97b530f98c28 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -115,7 +115,7 @@ object GhostTracker { private val patternGroup = RepoPattern.group("combat.ghosttracker") /** - * REGEX-TEST: §5§l+20 Kill Combo §r§8§r§3+15☯ Combat Wisdom + * REGEX-TEST: §6§lRARE DROP! §r§9Sorrow §r§b(+§r§b210% §r§b✯ Magic Find§r§b) */ private val itemDropPattern by patternGroup.pattern( "itemdrop", From 8d7261b0553d69c40c9c34fe1aee316541cc8479 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 24 Nov 2024 01:27:49 +0100 Subject: [PATCH 24/27] code cleanup --- .../repo/{GhostDrops.kt => GhostDropsJson.kt} | 2 +- .../combat/ghosttracker/GhostTracker.kt | 119 +++++++++--------- 2 files changed, 59 insertions(+), 62 deletions(-) rename src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/{GhostDrops.kt => GhostDropsJson.kt} (91%) diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDropsJson.kt similarity index 91% rename from src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.kt rename to src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDropsJson.kt index 86ad90b45e24..a59f073c03b1 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDrops.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/GhostDropsJson.kt @@ -4,6 +4,6 @@ import at.hannibal2.skyhanni.utils.NEUInternalName import com.google.gson.annotations.Expose import com.google.gson.annotations.SerializedName -data class GhostDrops( +data class GhostDropsJson( @Expose @SerializedName("ghost_drops") val ghostDrops: Set, ) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index 97b530f98c28..87f3606b87f5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -7,7 +7,7 @@ import at.hannibal2.skyhanni.config.commands.CommandCategory import at.hannibal2.skyhanni.config.commands.CommandRegistrationEvent import at.hannibal2.skyhanni.data.IslandType import at.hannibal2.skyhanni.data.ProfileStorageData -import at.hannibal2.skyhanni.data.jsonobjects.repo.GhostDrops +import at.hannibal2.skyhanni.data.jsonobjects.repo.GhostDropsJson import at.hannibal2.skyhanni.data.model.TabWidget import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.GuiRenderEvent @@ -27,6 +27,7 @@ import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatInt +import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches @@ -161,23 +162,21 @@ object GhostTracker { add(tracker.addTotalProfit(profit, data.kills, "kill")) } - private fun getLine(line: GhostTrackerLines, data: Data): String { - return when (line) { - GhostTrackerLines.KILLS -> "§7Kills: §e${data.kills.addSeparators()}" - GhostTrackerLines.GHOSTS_SINCE_SORROW -> "§7Ghosts Since Sorrow: §e${data.ghostsSinceSorrow.addSeparators()}" - GhostTrackerLines.MAX_KILL_COMBO -> "§7Max Kill Combo: §e${data.maxKillCombo.addSeparators()}" - GhostTrackerLines.COMBAT_XP_GAINED -> "§7Combat XP Gained: §e${data.combatXpGained.addSeparators()}" - GhostTrackerLines.AVERAGE_MAGIC_FIND -> - "§7Average Magic Find: §e${ - getAverageMagicFind( - data.totalMagicFind, - data.totalMagicFindKills, - ) - }" - - GhostTrackerLines.BESTIARY_KILLS -> - "§7Bestiary Kills: §e" + if (currentBestiaryKills >= MAX_BESTIARY_KILLS) "MAX" else currentBestiaryKills.addSeparators() - } + private fun getLine(line: GhostTrackerLines, data: Data): String = when (line) { + GhostTrackerLines.KILLS -> "§7Kills: §e${data.kills.addSeparators()}" + GhostTrackerLines.GHOSTS_SINCE_SORROW -> "§7Ghosts Since Sorrow: §e${data.ghostsSinceSorrow.addSeparators()}" + GhostTrackerLines.MAX_KILL_COMBO -> "§7Max Kill Combo: §e${data.maxKillCombo.addSeparators()}" + GhostTrackerLines.COMBAT_XP_GAINED -> "§7Combat XP Gained: §e${data.combatXpGained.addSeparators()}" + GhostTrackerLines.AVERAGE_MAGIC_FIND -> + "§7Average Magic Find: §e${ + getAverageMagicFind( + data.totalMagicFind, + data.totalMagicFindKills, + ) + }" + + GhostTrackerLines.BESTIARY_KILLS -> + "§7Bestiary Kills: §e" + if (currentBestiaryKills >= MAX_BESTIARY_KILLS) "MAX" else currentBestiaryKills.addSeparators() } @SubscribeEvent @@ -217,7 +216,7 @@ object GhostTracker { return } killComboEndPattern.matchMatcher(event.message) { - val kill = group("kill").formatInt().toLong() + val kill = group("kill").formatLong() tracker.modify { it.maxKillCombo = kill.coerceAtLeast(it.maxKillCombo) } @@ -233,28 +232,28 @@ object GhostTracker { fun onWidgetUpdate(event: WidgetUpdateEvent) { if (!event.isWidget(TabWidget.BESTIARY)) return if (isMaxBestiary || !isEnabled()) return - event.lines.forEach { line -> - bestiaryTablistPattern.matchMatcher(line) { - val kills = group("kills").formatInt().toLong() - if (kills <= currentBestiaryKills) return - val difference = kills - currentBestiaryKills - - if (difference > 50) { - currentBestiaryKills = kills - return - } + for (line in event.lines) { + if (maxBestiaryTablistPattern.matches(line)) { + currentBestiaryKills = MAX_BESTIARY_KILLS.toLong() + continue + } - currentBestiaryKills = kills + val kills = bestiaryTablistPattern.matchMatcher(line) { + group("kills").formatInt().toLong() + } ?: continue + if (kills <= currentBestiaryKills) continue + val difference = kills - currentBestiaryKills - tracker.modify { - it.kills += difference - it.ghostsSinceSorrow += difference - } - return + if (difference > 50) { + currentBestiaryKills = kills + continue } - if (maxBestiaryTablistPattern.matches(line)) { - currentBestiaryKills = MAX_BESTIARY_KILLS.toLong() - return + + currentBestiaryKills = kills + + tracker.modify { + it.kills += difference + it.ghostsSinceSorrow += difference } } } @@ -268,7 +267,7 @@ object GhostTracker { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { - allowedDrops = event.getConstant("GhostDrops").ghostDrops + allowedDrops = event.getConstant("GhostDrops").ghostDrops } @HandleEvent @@ -337,23 +336,21 @@ object GhostTracker { return killsUntilLevel } - private fun getBestiaryKillsInLevel(level: Int): Int { - return when (level) { - 1, 2, 3, 4, 5 -> 4 - 6 -> 20 - 7 -> 40 - 8, 9 -> 60 - 10 -> 100 - 11 -> 300 - 12 -> 600 - 13 -> 800 - 14, 15, 16, 17 -> 1_000 - 18 -> 1_200 - 19, 20 -> 1_400 - 21 -> 10_000 - 22, 23, 24, 25 -> 20_000 - else -> 0 - } + private fun getBestiaryKillsInLevel(level: Int): Int = when (level) { + 1, 2, 3, 4, 5 -> 4 + 6 -> 20 + 7 -> 40 + 8, 9 -> 60 + 10 -> 100 + 11 -> 300 + 12 -> 600 + 13 -> 800 + 14, 15, 16, 17 -> 1_000 + 18 -> 1_200 + 19, 20 -> 1_400 + 21 -> 10_000 + 22, 23, 24, 25 -> 20_000 + else -> 0 } @SubscribeEvent @@ -361,11 +358,11 @@ object GhostTracker { fun migrateItem(oldData: JsonElement): JsonElement { val oldAmount = oldData.asInt - val newData = JsonObject() - newData.addProperty("timesGained", oldAmount) - newData.addProperty("totalAmount", oldAmount) - newData.addProperty("hidden", false) - return newData + return JsonObject().apply { + addProperty("timesGained", oldAmount) + addProperty("totalAmount", oldAmount) + addProperty("hidden", false) + } } event.move(67, "#profile.ghostCounter.data.KILLS", "#profile.ghostStorage.ghostTracker.kills") From a1ba805276edd1ff8a8b8b814ec4c6cff5c4fe56 Mon Sep 17 00:00:00 2001 From: Empa Date: Sun, 24 Nov 2024 10:20:14 +0100 Subject: [PATCH 25/27] add warnings when bestiary widget empty Signed-off-by: Empa --- .../GhostProfitTrackerConfig.java | 6 + .../skyhanni/data/model/TabWidget.kt | 4 +- .../combat/ghosttracker/GhostTracker.kt | 176 ++++++++++-------- 3 files changed, 103 insertions(+), 83 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/GhostProfitTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/GhostProfitTrackerConfig.java index 93f66d175e03..c16b1d90c6c0 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/GhostProfitTrackerConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/combat/ghostcounter/GhostProfitTrackerConfig.java @@ -6,6 +6,7 @@ import com.google.gson.annotations.Expose; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDraggableList; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorInfoText; import io.github.notenoughupdates.moulconfig.annotations.ConfigLink; import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; @@ -36,6 +37,11 @@ public class GhostProfitTrackerConfig { GhostTracker.GhostTrackerLines.BESTIARY_KILLS )); + @Expose + @ConfigOption(name = "Max Bestiary", desc = "§7This feature will currently not work properly when having max Ghost Bestiary.") + @ConfigEditorInfoText(infoTitle = "Warning") + public String useless; + @Expose @ConfigLink(owner = GhostProfitTrackerConfig.class, field = "enabled") public Position position = new Position(50, 50, false, true); diff --git a/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt b/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt index c5dcc6032254..33313d801a90 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/model/TabWidget.kt @@ -315,8 +315,7 @@ enum class TabWidget( EVENT_TRACKERS( // language=RegExp "§e§lEvent Trackers:", - ) - + ), ; /** The pattern for the first line of the widget*/ @@ -331,6 +330,7 @@ enum class TabWidget( /** Both are inclusive */ var boundary = -1 to -1 + private set /** Is this widget currently visible in the tab list */ var isActive: Boolean = false diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index 87f3606b87f5..c1949ea6ab56 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -16,11 +16,14 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.PurseChangeCause import at.hannibal2.skyhanni.events.PurseChangeEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.events.SecondPassedEvent import at.hannibal2.skyhanni.events.SkillExpGainEvent import at.hannibal2.skyhanni.events.WidgetUpdateEvent import at.hannibal2.skyhanni.events.skyblock.GraphAreaChangeEvent import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.ChatUtils import at.hannibal2.skyhanni.utils.CollectionUtils.addSearchString +import at.hannibal2.skyhanni.utils.HypixelCommands import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland import at.hannibal2.skyhanni.utils.NEUInternalName @@ -29,8 +32,10 @@ import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat +import at.hannibal2.skyhanni.utils.RegexUtils.matchGroup import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches +import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.renderables.Searchable import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern import at.hannibal2.skyhanni.utils.tracker.ItemTrackerData @@ -39,6 +44,7 @@ import com.google.gson.JsonElement import com.google.gson.JsonObject import com.google.gson.annotations.Expose import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import kotlin.time.Duration.Companion.minutes @SkyHanniModule object GhostTracker { @@ -55,9 +61,15 @@ object GhostTracker { private val isMaxBestiary get() = currentBestiaryKills >= MAX_BESTIARY_KILLS private var allowedDrops = setOf() - private val MAX_BESTIARY_KILLS = getBestiaryKillsUntilLevel(25) + + // TODO: in the future get from neu bestiary data + private const val MAX_BESTIARY_KILLS = 100_000 + + private var lastNoWidgetWarningTime = SimpleTimeMark.farPast() + private var lastNoGhostBestiaryWidgetWarningTime = SimpleTimeMark.farPast() private var inArea: Boolean = false + private var foundGhostBestiary: Boolean = false private val tracker = SkyHanniItemTracker( "Ghost Tracker", @@ -136,11 +148,12 @@ object GhostTracker { ) /** + * REGEX-TEST: Ghost 21§r§f: §r§b29,614/40,000 * REGEX-TEST: Ghost 15§r§f: §r§b12,449/12,500 */ private val bestiaryTablistPattern by patternGroup.pattern( "tablist.bestiary", - "\\s*Ghost (?\\d+|[XVI]+)(?:§.)*: (?:§.)*(?[\\d,.]+)/(?[\\d,.]+)", + "\\s*Ghost (?\\d+|[XVI]+)(?:§.)*: (?:§.)*(?[\\d,.]+)\\/(?[\\d,.]+)", ) /** @@ -157,28 +170,11 @@ object GhostTracker { addSearchString("§e§lGhost Profit Tracker") val profit = tracker.drawItems(data, { true }, this) config.ghostTrackerText.forEach { line -> - addSearchString(getLine(line, data)) + addSearchString(line.line(data)) } add(tracker.addTotalProfit(profit, data.kills, "kill")) } - private fun getLine(line: GhostTrackerLines, data: Data): String = when (line) { - GhostTrackerLines.KILLS -> "§7Kills: §e${data.kills.addSeparators()}" - GhostTrackerLines.GHOSTS_SINCE_SORROW -> "§7Ghosts Since Sorrow: §e${data.ghostsSinceSorrow.addSeparators()}" - GhostTrackerLines.MAX_KILL_COMBO -> "§7Max Kill Combo: §e${data.maxKillCombo.addSeparators()}" - GhostTrackerLines.COMBAT_XP_GAINED -> "§7Combat XP Gained: §e${data.combatXpGained.addSeparators()}" - GhostTrackerLines.AVERAGE_MAGIC_FIND -> - "§7Average Magic Find: §e${ - getAverageMagicFind( - data.totalMagicFind, - data.totalMagicFindKills, - ) - }" - - GhostTrackerLines.BESTIARY_KILLS -> - "§7Bestiary Kills: §e" + if (currentBestiaryKills >= MAX_BESTIARY_KILLS) "MAX" else currentBestiaryKills.addSeparators() - } - @SubscribeEvent fun onSkillExp(event: SkillExpGainEvent) { if (!isEnabled()) return @@ -188,6 +184,29 @@ object GhostTracker { } } + @SubscribeEvent + fun onSecond(event: SecondPassedEvent) { + if (!isEnabled()) return + if (!TabWidget.BESTIARY.isActive && lastNoWidgetWarningTime.passedSince() > 1.minutes) { + lastNoWidgetWarningTime = SimpleTimeMark.now() + ChatUtils.clickableChat( + "§cYou do not have the Bestiary Tab Widget enabled! Ghost Tracker will not work properly without it.", + onClick = HypixelCommands::widget, + "§eClick to run /widget!", + replaceSameMessage = true, + ) + } + if (!foundGhostBestiary && lastNoGhostBestiaryWidgetWarningTime.passedSince() > 1.minutes) { + lastNoGhostBestiaryWidgetWarningTime = SimpleTimeMark.now() + ChatUtils.clickableChat( + "§Ghost bestiary not found in Bestiary Tab Widget! Ghost Tracker will not work properly without it.", + onClick = HypixelCommands::widget, + "§eClick to run /widget!", + replaceSameMessage = true, + ) + } + } + @SubscribeEvent fun onPurseChange(event: PurseChangeEvent) { if (!isEnabled()) return @@ -228,25 +247,23 @@ object GhostTracker { } } - @SubscribeEvent - fun onWidgetUpdate(event: WidgetUpdateEvent) { - if (!event.isWidget(TabWidget.BESTIARY)) return - if (isMaxBestiary || !isEnabled()) return - for (line in event.lines) { + private fun parseBestiaryWidget(lines: List) { + foundGhostBestiary = false + for (line in lines) { if (maxBestiaryTablistPattern.matches(line)) { currentBestiaryKills = MAX_BESTIARY_KILLS.toLong() - continue + foundGhostBestiary = true + return } - val kills = bestiaryTablistPattern.matchMatcher(line) { - group("kills").formatInt().toLong() - } ?: continue - if (kills <= currentBestiaryKills) continue + val kills = bestiaryTablistPattern.matchGroup(line, "kills")?.formatLong() ?: continue + foundGhostBestiary = true + if (kills <= currentBestiaryKills) return val difference = kills - currentBestiaryKills if (difference > 50) { currentBestiaryKills = kills - continue + return } currentBestiaryKills = kills @@ -258,6 +275,13 @@ object GhostTracker { } } + @SubscribeEvent + fun onWidgetUpdate(event: WidgetUpdateEvent) { + if (!event.isWidget(TabWidget.BESTIARY)) return + if (isMaxBestiary || !isEnabled()) return + parseBestiaryWidget(event.lines) + } + @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent) { if (!isEnabled()) return @@ -273,6 +297,7 @@ object GhostTracker { @HandleEvent fun onAreaChange(event: GraphAreaChangeEvent) { inArea = event.area == "The Mist" && IslandType.DWARVEN_MINES.isInIsland() + if (inArea) parseBestiaryWidget(TabWidget.BESTIARY.lines) } @SubscribeEvent @@ -290,18 +315,34 @@ object GhostTracker { private fun isEnabled() = inArea && config.enabled - enum class GhostTrackerLines(private val display: String) { - KILLS("§7Kills: §e7,813"), - GHOSTS_SINCE_SORROW("§7Ghosts Since Sorrow: §e71"), - MAX_KILL_COMBO("§7Max Kill Combo: §e681"), - COMBAT_XP_GAINED("§7Combat XP Gained: §e4,687,800"), - AVERAGE_MAGIC_FIND("§7Average Magic Find: §b278.9"), - BESTIARY_KILLS("§7Bestiary Kills: §e 71,893"), + enum class GhostTrackerLines(private val display: String, val line: Data.() -> String) { + KILLS( + "§7Kills: §e7,813", + { "§7Kills: §e${kills.addSeparators()}" } + ), + GHOSTS_SINCE_SORROW( + "§7Ghosts Since Sorrow: §e71", + { "§7Ghosts Since Sorrow: §e${ghostsSinceSorrow.addSeparators()}" }, + ), + MAX_KILL_COMBO( + "§7Max Kill Combo: §e681", + { "§7Max Kill Combo: §e${maxKillCombo.addSeparators()}" }, + ), + COMBAT_XP_GAINED( + "§7Combat XP Gained: §e4,687,800", + { "§7Combat XP Gained: §e${combatXpGained.addSeparators()}" }, + ), + AVERAGE_MAGIC_FIND( + "§7Average Magic Find: §b278.9", + { "§7Average Magic Find: §e${getAverageMagicFind(totalMagicFind, totalMagicFindKills)}" }, + ), + BESTIARY_KILLS( + "§7Bestiary Kills: §e 71,893", + { "§7Bestiary Kills: §e" + if (currentBestiaryKills >= MAX_BESTIARY_KILLS) "MAX" else currentBestiaryKills.addSeparators() }, + ), ; - override fun toString(): String { - return display - } + override fun toString(): String = display } @SubscribeEvent @@ -309,11 +350,7 @@ object GhostTracker { val storage = storage ?: return if (storage.migratedTotalKills) return tracker.modify { - var count = 0L - it.items.forEach { (_, item) -> - count += item.timesGained.toInt() - } - it.totalMagicFindKills = count + it.totalMagicFindKills = it.items.values.sumOf { item -> item.timesGained } } storage.migratedTotalKills = true } @@ -327,32 +364,6 @@ object GhostTracker { } } - // TODO: In the future move to a utils class and use neu bestiary data - private fun getBestiaryKillsUntilLevel(level: Int): Int { - var killsUntilLevel = 0 - for (i in 1..level) { - killsUntilLevel += getBestiaryKillsInLevel(i) - } - return killsUntilLevel - } - - private fun getBestiaryKillsInLevel(level: Int): Int = when (level) { - 1, 2, 3, 4, 5 -> 4 - 6 -> 20 - 7 -> 40 - 8, 9 -> 60 - 10 -> 100 - 11 -> 300 - 12 -> 600 - 13 -> 800 - 14, 15, 16, 17 -> 1_000 - 18 -> 1_200 - 19, 20 -> 1_400 - 21 -> 10_000 - 22, 23, 24, 25 -> 20_000 - else -> 0 - } - @SubscribeEvent fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { @@ -365,15 +376,18 @@ object GhostTracker { } } - event.move(67, "#profile.ghostCounter.data.KILLS", "#profile.ghostStorage.ghostTracker.kills") - event.move(67, "#profile.ghostCounter.data.GHOSTSINCESORROW", "#profile.ghostStorage.ghostTracker.ghostsSinceSorrow") - event.move(67, "#profile.ghostCounter.data.MAXKILLCOMBO", "#profile.ghostStorage.ghostTracker.maxKillCombo") - event.move(67, "#profile.ghostCounter.data.SKILLXPGAINED", "#profile.ghostStorage.ghostTracker.combatXpGained") - event.move(67, "#profile.ghostCounter.totalMF", "#profile.ghostStorage.ghostTracker.totalMagicFind") + val oldPrefix = "#profile.ghostCounter" + val newPrefix = "#profile.ghostStorage.ghostTracker" + + event.move(67, "$oldPrefix.data.KILLS", "$newPrefix.kills") + event.move(67, "$oldPrefix.data.GHOSTSINCESORROW", "$newPrefix.ghostsSinceSorrow") + event.move(67, "$oldPrefix.data.MAXKILLCOMBO", "$newPrefix.maxKillCombo") + event.move(67, "$oldPrefix.data.SKILLXPGAINED", "$newPrefix.combatXpGained") + event.move(67, "$oldPrefix.totalMF", "$newPrefix.totalMagicFind") - event.move(67, "#profile.ghostCounter.data.SORROWCOUNT", "#profile.ghostStorage.ghostTracker.items.SORROW", ::migrateItem) - event.move(67, "#profile.ghostCounter.data.PLASMACOUNT", "#profile.ghostStorage.ghostTracker.items.PLASMA", ::migrateItem) - event.move(67, "#profile.ghostCounter.data.VOLTACOUNT", "#profile.ghostStorage.ghostTracker.items.VOLTA", ::migrateItem) - event.move(67, "#profile.ghostCounter.data.GHOSTLYBOOTS", "#profile.ghostStorage.ghostTracker.items.GHOST_BOOTS", ::migrateItem) + event.move(67, "$oldPrefix.data.SORROWCOUNT", "$newPrefix.items.SORROW", ::migrateItem) + event.move(67, "$oldPrefix.data.PLASMACOUNT", "$newPrefix.items.PLASMA", ::migrateItem) + event.move(67, "$oldPrefix.data.VOLTACOUNT", "$newPrefix.items.VOLTA", ::migrateItem) + event.move(67, "$oldPrefix.data.GHOSTLYBOOTS", "$newPrefix.items.GHOST_BOOTS", ::migrateItem) } } From 2692d0b61198ea302fdb4bb5a47d0cc529d20613 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 24 Nov 2024 21:38:34 +0100 Subject: [PATCH 26/27] make detekt happy --- .../skyhanni/features/combat/ghosttracker/GhostTracker.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index c1949ea6ab56..64f1de0df3e0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -338,7 +338,10 @@ object GhostTracker { ), BESTIARY_KILLS( "§7Bestiary Kills: §e 71,893", - { "§7Bestiary Kills: §e" + if (currentBestiaryKills >= MAX_BESTIARY_KILLS) "MAX" else currentBestiaryKills.addSeparators() }, + { + val kills = if (currentBestiaryKills >= MAX_BESTIARY_KILLS) "MAX" else currentBestiaryKills.addSeparators() + "§7Bestiary Kills: §e$kills" + }, ), ; From 7c519944ab2ef783b873835af9c2b1e2afd5221b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 24 Nov 2024 22:00:11 +0100 Subject: [PATCH 27/27] fix formatting, typos and don't show both tab error messages at once, --- .../skyhanni/features/combat/ghosttracker/GhostTracker.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt index 64f1de0df3e0..99a5eb34b7a2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghosttracker/GhostTracker.kt @@ -31,6 +31,7 @@ import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.toInternalName import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators import at.hannibal2.skyhanni.utils.NumberUtil.formatInt import at.hannibal2.skyhanni.utils.NumberUtil.formatLong +import at.hannibal2.skyhanni.utils.NumberUtil.roundTo import at.hannibal2.skyhanni.utils.NumberUtil.shortFormat import at.hannibal2.skyhanni.utils.RegexUtils.matchGroup import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher @@ -196,10 +197,10 @@ object GhostTracker { replaceSameMessage = true, ) } - if (!foundGhostBestiary && lastNoGhostBestiaryWidgetWarningTime.passedSince() > 1.minutes) { + if (TabWidget.BESTIARY.isActive && !foundGhostBestiary && lastNoGhostBestiaryWidgetWarningTime.passedSince() > 1.minutes) { lastNoGhostBestiaryWidgetWarningTime = SimpleTimeMark.now() ChatUtils.clickableChat( - "§Ghost bestiary not found in Bestiary Tab Widget! Ghost Tracker will not work properly without it.", + "§cGhost bestiary not found in Bestiary Tab Widget! Ghost Tracker will not work properly without it.", onClick = HypixelCommands::widget, "§eClick to run /widget!", replaceSameMessage = true, @@ -334,7 +335,7 @@ object GhostTracker { ), AVERAGE_MAGIC_FIND( "§7Average Magic Find: §b278.9", - { "§7Average Magic Find: §e${getAverageMagicFind(totalMagicFind, totalMagicFindKills)}" }, + { "§7Average Magic Find: §e${getAverageMagicFind(totalMagicFind, totalMagicFindKills).roundTo(1)}" }, ), BESTIARY_KILLS( "§7Bestiary Kills: §e 71,893",