aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/fishing
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-09-07 07:05:45 +0200
committerGitHub <noreply@github.com>2024-09-07 07:05:45 +0200
commit02c9ce15e053d5d0751c32ea3ef481c9eef7a904 (patch)
treeee7f200d2e4ba2555aaa54b336d3d0ecbc47558f /src/main/java/at/hannibal2/skyhanni/features/fishing
parent78ce109b8fe6291340067771217b6965d82d76c2 (diff)
downloadskyhanni-02c9ce15e053d5d0751c32ea3ef481c9eef7a904.tar.gz
skyhanni-02c9ce15e053d5d0751c32ea3ef481c9eef7a904.tar.bz2
skyhanni-02c9ce15e053d5d0751c32ea3ef481c9eef7a904.zip
Feature: /shedittracker (#2448)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/fishing')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt
index b99c03ff5..a0590816e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/FishingProfitTracker.kt
@@ -1,6 +1,7 @@
package at.hannibal2.skyhanni.features.fishing.tracker
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.ItemAddManager
import at.hannibal2.skyhanni.data.jsonobjects.repo.FishingProfitItemsJson
import at.hannibal2.skyhanni.events.FishingBobberCastEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
@@ -43,14 +44,15 @@ object FishingProfitTracker {
private val coinsChatPattern by RepoPattern.pattern(
"fishing.tracker.chat.coins",
- ".* CATCH! §r§bYou found §r§6(?<coins>.*) Coins§r§b\\."
+ ".* CATCH! §r§bYou found §r§6(?<coins>.*) Coins§r§b\\.",
)
private var lastCatchTime = SimpleTimeMark.farPast()
private val tracker = SkyHanniItemTracker(
"Fishing Profit Tracker",
{ Data() },
- { it.fishing.fishingProfitTracker }) { drawDisplay(it) }
+ { it.fishing.fishingProfitTracker },
+ ) { drawDisplay(it) }
class Data : ItemTrackerData() {
@@ -64,7 +66,7 @@ object FishingProfitTracker {
return listOf(
"§7Caught §e${timesCaught.addSeparators()} §7times.",
- "§7Your catch rate: §c$catchRate"
+ "§7Your catch rate: §c$catchRate",
)
}
@@ -73,7 +75,7 @@ object FishingProfitTracker {
override fun getCoinDescription(item: TrackedItem): List<String> {
val mobKillCoinsFormat = item.totalAmount.shortFormat()
return listOf(
- "§7You fished up §6$mobKillCoinsFormat coins §7already."
+ "§7You fished up §6$mobKillCoinsFormat coins §7already.",
)
}
@@ -127,8 +129,8 @@ object FishingProfitTracker {
addAsSingletonList(
Renderable.hoverTips(
"§7Times fished: §e${fishedCount.addSeparators()}",
- listOf("§7You've reeled in §e${fishedCount.addSeparators()} §7catches.")
- )
+ listOf("§7You've reeled in §e${fishedCount.addSeparators()} §7catches."),
+ ),
)
addAsSingletonList(tracker.addTotalProfit(profit, data.totalCatchAmount, "catch"))
@@ -152,7 +154,7 @@ object FishingProfitTracker {
val id = list.indexOf(currentCategory)
currentCategory = list[(id + 1) % list.size]
tracker.update()
- }
+ },
)
}
@@ -178,7 +180,7 @@ object FishingProfitTracker {
"Loaded $label not in a fishing category",
"Found items missing in itemCategories",
"missingItems" to missingItems,
- noStackTrace = true
+ noStackTrace = true,
)
}
}
@@ -186,15 +188,21 @@ object FishingProfitTracker {
@SubscribeEvent
fun onItemAdd(event: ItemAddEvent) {
if (!isEnabled()) return
+
+ if (event.source == ItemAddManager.Source.COMMAND) {
+ tryAddItem(event.internalName, event.amount, command = true)
+ return
+ }
+
DelayedRun.runDelayed(500.milliseconds) {
- maybeAddItem(event.internalName, event.amount)
+ tryAddItem(event.internalName, event.amount, command = false)
}
}
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
coinsChatPattern.matchMatcher(event.message) {
- tracker.addCoins(group("coins").formatInt())
+ tryAddItem(NEUInternalName.SKYBLOCK_COIN, group("coins").formatInt(), command = false)
addCatch()
}
}
@@ -221,14 +229,14 @@ object FishingProfitTracker {
lastCatchTime = SimpleTimeMark.farPast()
}
- private fun maybeAddItem(internalName: NEUInternalName, amount: Int) {
+ private fun tryAddItem(internalName: NEUInternalName, amount: Int, command: Boolean) {
if (!FishingAPI.isFishing(checkRodInHand = false)) return
if (!isAllowedItem(internalName)) {
ChatUtils.debug("Ignored non-fishing item pickup: $internalName'")
return
}
- tracker.addItem(internalName, amount)
+ tracker.addItem(internalName, amount, command)
addCatch()
}