aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2024-03-12 02:27:36 +1100
committerGitHub <noreply@github.com>2024-03-11 16:27:36 +0100
commit9637398e94e41a1bb8787d2ef5bce6b839606b57 (patch)
treec1925ba00fdef3c14d0a494be54606fdcd49f22d /src/main/java
parent76fd1aa7306e52beb0640499329d12491971f351 (diff)
downloadskyhanni-9637398e94e41a1bb8787d2ef5bce6b839606b57.tar.gz
skyhanni-9637398e94e41a1bb8787d2ef5bce6b839606b57.tar.bz2
skyhanni-9637398e94e41a1bb8787d2ef5bce6b839606b57.zip
Fix: Some issues in event tracker (#1142)
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventType.kt17
3 files changed, 21 insertions, 16 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt
index 7281da5a3..656df781f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt
@@ -77,10 +77,11 @@ object MiningEventDisplay {
eventData.runningEvents.forEach { (islandType, events) ->
when (islandType) {
IslandType.DWARVEN_MINES -> dwarvenEvents =
- (events.sortedBy { it.endsAt - it.event.defaultLength.inWholeMilliseconds })
+ events.sortedBy { it.endsAt - it.event.defaultLength.inWholeMilliseconds }
IslandType.CRYSTAL_HOLLOWS -> crystalEvents =
- (events.sortedBy { it.endsAt - it.event.defaultLength.inWholeMilliseconds })
+ events.filter { !it.event.dwarvenSpecific }
+ .sortedBy { it.endsAt - it.event.defaultLength.inWholeMilliseconds }
else -> Unit
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt
index 137aecec2..a3a9b979f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.config.ConfigManager
import at.hannibal2.skyhanni.data.BossbarData
import at.hannibal2.skyhanni.data.HypixelData
+import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.ScoreboardData
import at.hannibal2.skyhanni.events.BossbarUpdateEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
@@ -12,6 +13,7 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.test.command.ErrorManager
import at.hannibal2.skyhanni.utils.APIUtil
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.TabListData
@@ -63,7 +65,7 @@ class MiningEventTracker {
@SubscribeEvent
fun onBossbarChange(event: BossbarUpdateEvent) {
if (!LorenzUtils.inAdvancedMiningIsland()) return
- if (lastWorldSwitch.passedSince() < 2.seconds) return
+ if (lastWorldSwitch.passedSince() < 5.seconds) return
if (!eventEndTime.isInPast()) {
return
}
@@ -99,9 +101,7 @@ class MiningEventTracker {
}
private fun sendData(eventName: String, time: String?) {
- val eventType = MiningEventType.fromBossbarName(eventName)
- if (lastSentEvent == eventType) return
- if (eventType == null) {
+ val eventType = MiningEventType.fromEventName(eventName) ?: run {
if (!config.enabled) return
ErrorManager.logErrorWithData(
Exception("UnknownMiningEvent"), "Unknown mining event detected from string $eventName",
@@ -112,6 +112,10 @@ class MiningEventTracker {
)
return
}
+
+ if (IslandType.CRYSTAL_HOLLOWS.isInIsland() && eventType.dwarvenSpecific) return
+
+ if (lastSentEvent == eventType) return
lastSentEvent = eventType
val timeRemaining = if (time == null) {
@@ -121,8 +125,7 @@ class MiningEventTracker {
}
eventEndTime = SimpleTimeMark.now() + timeRemaining
- val serverId = HypixelData.getCurrentServerId()
- if (serverId == null) {
+ val serverId = HypixelData.getCurrentServerId() ?: run {
ErrorManager.logErrorWithData(
Exception("NoServerId"), "Could not find server id",
"islandType" to LorenzUtils.skyBlockIsland,
diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventType.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventType.kt
index b8fb1d35a..b71f8431f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventType.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventType.kt
@@ -10,14 +10,15 @@ enum class MiningEventType(
val eventName: String,
private val shortName: String,
val defaultLength: Duration,
- private val colourCode: Char
+ private val colourCode: Char,
+ val dwarvenSpecific: Boolean,
) {
- GONE_WITH_THE_WIND("GONE WITH THE WIND", "Wind", 18.minutes, '9'),
- DOUBLE_POWDER("2X POWDER", "2x", 15.minutes, 'b'),
- GOBLIN_RAID("GOBLIN RAID", "Raid", 5.minutes, 'c'),
- BETTER_TOGETHER("BETTER TOGETHER", "Better", 18.minutes, 'd'),
- RAFFLE("RAFFLE", "Raffle", 160.seconds, '6'),
- MITHRIL_GOURMAND("MITHRIL GOURMAND", "Gourmand", 10.minutes, 'b'),
+ GONE_WITH_THE_WIND("GONE WITH THE WIND", "Wind", 18.minutes, '9', false),
+ DOUBLE_POWDER("2X POWDER", "2x", 15.minutes, 'b', false),
+ GOBLIN_RAID("GOBLIN RAID", "Raid", 5.minutes, 'c', true),
+ BETTER_TOGETHER("BETTER TOGETHER", "Better", 18.minutes, 'd', false),
+ RAFFLE("RAFFLE", "Raffle", 160.seconds, '6', true),
+ MITHRIL_GOURMAND("MITHRIL GOURMAND", "Gourmand", 10.minutes, 'b', true),
;
override fun toString() =
@@ -29,7 +30,7 @@ enum class MiningEventType(
companion object {
private val config get() = SkyHanniMod.feature.mining.miningEvent
- fun fromBossbarName(bossbarName: String): MiningEventType? {
+ fun fromEventName(bossbarName: String): MiningEventType? {
return MiningEventType.entries.find { it.eventName == bossbarName.removeColor() }
}
}