aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-03-19 12:30:28 +0100
committerGitHub <noreply@github.com>2024-03-19 12:30:28 +0100
commit1c0cb4f9accae5072540ee032b411063c0393ee0 (patch)
treec0d62f83a9f8b2a60b5eb6bd8e57660678150d65 /src/main/java/at/hannibal2
parent486761ae31c9d81910b4944aaa47418a009d04b1 (diff)
downloadskyhanni-1c0cb4f9accae5072540ee032b411063c0393ee0.tar.gz
skyhanni-1c0cb4f9accae5072540ee032b411063c0393ee0.tar.bz2
skyhanni-1c0cb4f9accae5072540ee032b411063c0393ee0.zip
Fix: getting slayer spawn cost from bank (#1218)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt
index fefc5cf0c..9a709e43b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerProfitTracker.kt
@@ -7,6 +7,7 @@ import at.hannibal2.skyhanni.data.SlayerAPI
import at.hannibal2.skyhanni.data.jsonobjects.repo.SlayerProfitTrackerItemsJson
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.ItemAddEvent
+import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.PurseChangeCause
import at.hannibal2.skyhanni.events.PurseChangeEvent
import at.hannibal2.skyhanni.events.RepositoryReloadEvent
@@ -18,8 +19,11 @@ import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NumberUtil
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.renderables.Renderable
+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.JsonObject
@@ -35,6 +39,14 @@ object SlayerProfitTracker {
private var baseSlayerType = ""
private val trackers = mutableMapOf<String, SkyHanniItemTracker<Data>>()
+ /**
+ * REGEX-TEST: §7Took 1.9k coins from your bank for auto-slayer...
+ */
+ private val autoSlayerBankPattern by RepoPattern.pattern(
+ "slayer.autoslayer.bank.chat",
+ "§7Took (?<coins>.+) coins from your bank for auto-slayer\\.\\.\\."
+ )
+
class Data : ItemTrackerData() {
override fun resetItems() {
@@ -71,9 +83,9 @@ object SlayerProfitTracker {
private val ItemTrackerData.TrackedItem.timesDropped get() = timesGained
- private fun addSlayerCosts(price: Int) {
+ private fun addSlayerCosts(price: Double) {
getTracker()?.modify {
- it.slayerSpawnCost += price
+ it.slayerSpawnCost += price.toInt()
}
}
@@ -92,7 +104,15 @@ object SlayerProfitTracker {
getTracker()?.addCoins(coins.toInt())
}
if (event.reason == PurseChangeCause.LOSE_SLAYER_QUEST_STARTED) {
- addSlayerCosts(coins.toInt())
+ addSlayerCosts(coins)
+ }
+ }
+
+ @SubscribeEvent
+ fun onChat(event: LorenzChatEvent) {
+ if (!isEnabled()) return
+ autoSlayerBankPattern.matchMatcher(event.message) {
+ addSlayerCosts(group("coins").formatDouble())
}
}