summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/combat
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-04-07 21:36:08 +1000
committerGitHub <noreply@github.com>2024-04-07 13:36:08 +0200
commitfcd404d862b4b051474898076fcc06b406d1ea91 (patch)
tree7659d22a41d1529a8d4ebaa62958bc0934596431 /src/main/java/at/hannibal2/skyhanni/features/combat
parent03c416202ccdec17cc46f6d07aae111fa977771a (diff)
downloadskyhanni-fcd404d862b4b051474898076fcc06b406d1ea91.tar.gz
skyhanni-fcd404d862b4b051474898076fcc06b406d1ea91.tar.bz2
skyhanni-fcd404d862b4b051474898076fcc06b406d1ea91.zip
Backend: Remove a lot of deprecated code (#1371)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/combat')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt78
1 files changed, 40 insertions, 38 deletions
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
index 8f28038fa..0b0a444d9 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt
@@ -11,9 +11,9 @@ 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.LorenzTickEvent
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
@@ -44,7 +44,8 @@ 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.formatNumber
+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.roundToPrecision
import at.hannibal2.skyhanni.utils.OSUtils
@@ -103,7 +104,7 @@ object GhostCounter {
private var skillText = ""
private var lastParsedSkillSection = ""
private var lastSkillProgressString: String? = null
- private var lastXp: String = "0"
+ private var lastXp: Long = 0
private var gain: Int = 0
private var num: Double = 0.0
private var inMist = false
@@ -292,41 +293,42 @@ object GhostCounter {
}
@SubscribeEvent
- fun onTick(event: LorenzTickEvent) {
+ fun onSecondPassed(event: SecondPassedEvent) {
if (!isEnabled()) return
- if (event.repeatSeconds(1)) {
- skillXPPattern.matchMatcher(skillText) {
- val gained = group("gained").formatNumber().toDouble()
- val current = group("current")
- if (current != lastXp) {
- val res = current.formatNumber().toString()
- gain = (res.toLong() - lastXp.toLong()).toDouble().roundToInt()
- num = (gain.toDouble() / gained)
- if (gained in 150.0..450.0 && lastXp != "0" && 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 = res
+
+ 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()) {
- clickableChat(
- "GhostCounterV3 ChatTriggers module has been detected, do you want to import saved data ? Click here to import data",
- "shimportghostcounterdata",
- prefixColor = "§6",
- )
- }
+ }
+
+ if (notifyCTModule && ProfileStorageData.profileSpecific?.ghostCounter?.ctDataImported != true) {
+ notifyCTModule = false
+ if (isUsingCTGhostCounter()) {
+ clickableChat(
+ "GhostCounterV3 ChatTriggers module has been detected, do you want to import saved data ? Click here to import data",
+ "shimportghostcounterdata",
+ prefixColor = "§6",
+ )
}
- inMist = LorenzUtils.skyBlockArea == "The Mist"
- update()
}
+
+ inMist = LorenzUtils.skyBlockArea == "The Mist"
+ update()
+
if (event.repeatSeconds(2)) {
calculateXP()
calculateETA()
@@ -436,10 +438,10 @@ object GhostCounter {
}
killComboExpiredPattern.matchMatcher(event.message) {
if (Option.KILLCOMBO.getInt() > Option.MAXKILLCOMBO.getInt()) {
- Option.MAXKILLCOMBO.set(group("combo").formatNumber().toDouble())
+ Option.MAXKILLCOMBO.set(group("combo").formatDouble())
}
if (Option.KILLCOMBO.getInt() > Option.MAXKILLCOMBO.getInt(true)) {
- Option.MAXKILLCOMBO.set(group("combo").formatNumber().toDouble(), true)
+ Option.MAXKILLCOMBO.set(group("combo").formatDouble(), true)
}
Option.KILLCOMBOCOINS.set(0.0)
Option.KILLCOMBO.set(0.0)
@@ -490,11 +492,11 @@ object GhostCounter {
for (line in ghostStack.getLore()) {
val l = line.removeColor().trim()
if (l.startsWith("Kills: ")) {
- kills = "Kills: (.*)".toRegex().find(l)?.groupValues?.get(1)?.formatNumber()?.toDouble() ?: 0.0
+ 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").formatNumber().toDouble()
- storage?.bestiaryKillNeeded = group("total").formatNumber().toDouble()
+ storage?.bestiaryCurrentKill = if (kills > 0) kills else group("current").formatDouble()
+ storage?.bestiaryKillNeeded = group("total").formatDouble()
}
}
update()