aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authoralexia <me@alexia.lol>2024-01-11 13:38:45 +0100
committerGitHub <noreply@github.com>2024-01-11 13:38:45 +0100
commitb0fb9180d1d47c5bd01de536965cf3f630bfc1ba (patch)
treec355aed6964b0ad18f35386b1b664c28cdc8841b /src/main
parent8c5e53facf75158bd8b0f4875f71133bf6a365e3 (diff)
downloadskyhanni-b0fb9180d1d47c5bd01de536965cf3f630bfc1ba.tar.gz
skyhanni-b0fb9180d1d47c5bd01de536965cf3f630bfc1ba.tar.bz2
skyhanni-b0fb9180d1d47c5bd01de536965cf3f630bfc1ba.zip
Add ability to get unique visitors served without Green Thumb (#832)
Added ability to get unique visitors served without Green Thumb. #832
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt33
2 files changed, 39 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
index d40d02718..c7f05d807 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt
@@ -139,6 +139,12 @@ class FarmingFortuneDisplay {
if (upgradeFortune == null) {
updatedDisplay.addAsSingletonList("§cOpen §e/cropupgrades§c for more exact data!")
}
+
+ val uniqueVisitors = GardenAPI.storage?.uniqueVisitors?.toDouble() ?: 0.0
+ if (uniqueVisitors == 0.0) {
+ updatedDisplay.addAsSingletonList("§cOpen §e/visitormilestones§c for more exact data!")
+ }
+
if (accessoryFortune == null) {
updatedDisplay.addAsSingletonList("§cOpen Accessory Bag for more exact data!")
if (CropAccessoryData.isLoadingAccessories) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt
index 3f39ac198..2b3e5d04a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/CaptureFarmingGear.kt
@@ -18,6 +18,7 @@ import at.hannibal2.skyhanni.utils.SkyBlockItemModifierUtils.getEnchantments
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TabListData
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.math.round
import kotlin.time.Duration.Companion.days
@@ -37,6 +38,9 @@ class CaptureFarmingGear {
private val cakePattern = "(?:Big )?Yum! You (?:gain|refresh) [+]5☘ Farming Fortune for 48 hours!".toPattern()
+ private val tierPattern by RepoPattern.pattern("garden.uniqueVisitors.tier", "§7Progress to Tier (?<nextTier>\\d+):.*")
+ private val tierProgressPattern by RepoPattern.pattern("garden.uniqueVisitors.tierProgress", ".* §e(?<having>.*)§6/(?<total>.*)")
+
companion object {
private val strengthPattern = " Strength: §r§c❁(?<strength>.*)".toPattern()
private val farmingSets = arrayListOf(
@@ -90,6 +94,16 @@ class CaptureFarmingGear {
storage.pumpkinFortune = !storage.pumpkinFortune
LorenzUtils.chat("Toggled expired pumpkin fortune to: ${storage.pumpkinFortune}")
}
+
+ private fun getUniqueVisitorsForTier(tier: Int): Int {
+ return when {
+ tier == 0 -> 0
+ tier == 1 -> 1
+ tier == 2 -> 5
+ tier >= 3 -> 10 * (tier - 2)
+ else -> throw IllegalStateException("Unexpected unique visitors tier: $tier")
+ }
+ }
}
@SubscribeEvent
@@ -214,6 +228,25 @@ class CaptureFarmingGear {
storage.anitaUpgrade = level
}
}
+ if (event.inventoryName.contains("Visitor Milestones")) {
+ for ((_, item) in event.inventoryItems) {
+ if (item.displayName != "§aUnique Visitors Served") continue
+
+ var tier = -1
+ var tierProgress = -1
+ for (line in item.getLore()) {
+ tierPattern.matchMatcher(line) {
+ tier = group("nextTier").toInt() - 1
+ }
+ tierProgressPattern.matchMatcher(line) {
+ tierProgress = group("having").toInt()
+ }
+ }
+ if (tier > -1 && tierProgress > -1) {
+ GardenAPI.storage?.uniqueVisitors = getUniqueVisitorsForTier(tier) + tierProgress
+ }
+ }
+ }
}
@SubscribeEvent