aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningEventConfig.java1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventDisplay.kt80
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/mining/eventtracker/MiningEventTracker.kt11
3 files changed, 42 insertions, 50 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningEventConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningEventConfig.java
index 8f5dac292..f435c568f 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningEventConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningEventConfig.java
@@ -49,7 +49,6 @@ public class MiningEventConfig {
ALL("All Mining Islands"),
CRYSTAL("Crystal Hollows Only"),
DWARVEN("Dwarven Mines Only"),
- MINESHAFT("Mineshaft Only"),
CURRENT("Current Island Only"),
;
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 fc858de90..26f41c799 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
@@ -16,8 +16,6 @@ import at.hannibal2.skyhanni.utils.NEUItems.getItemStack
import at.hannibal2.skyhanni.utils.RenderUtils.renderRenderables
import at.hannibal2.skyhanni.utils.SimpleTimeMark.Companion.asTimeMark
import at.hannibal2.skyhanni.utils.renderables.Renderable
-import net.minecraft.init.Blocks
-import net.minecraft.item.ItemStack
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
@@ -25,7 +23,7 @@ object MiningEventDisplay {
private val config get() = SkyHanniMod.feature.mining.miningEvent
private var display = listOf<Renderable>()
- private val islandEventData: MutableMap<IslandType, MiningIslandEventInfo> = mutableMapOf()
+ private val islandEventData = mutableMapOf<IslandType, MiningIslandEventInfo>()
@SubscribeEvent
fun onSecondPassed(event: SecondPassedEvent) {
@@ -39,24 +37,20 @@ object MiningEventDisplay {
}
private fun updateDisplay() {
- display = emptyList()
- updateEvents()
+ display = updateEvents()
}
- private fun updateEvents() {
- val list = mutableListOf<Renderable>()
-
+ private fun updateEvents() = buildList {
if (MiningEventTracker.apiError) {
val count = MiningEventTracker.apiErrorCount
- list.add(Renderable.string("§cMining Event API Error! ($count)"))
- list.add(Renderable.string("§cSwap servers to try again!"))
+ add(Renderable.string("§cMining Event API Error! ($count)"))
+ add(Renderable.string("§cSwap servers to try again!"))
}
- islandEventData.forEach { (islandType, eventDetails) ->
+ for ((islandType, eventDetails) in islandEventData) {
val shouldShow = when (config.showType) {
MiningEventConfig.ShowType.DWARVEN -> islandType == IslandType.DWARVEN_MINES
MiningEventConfig.ShowType.CRYSTAL -> islandType == IslandType.CRYSTAL_HOLLOWS
- MiningEventConfig.ShowType.MINESHAFT -> islandType == IslandType.MINESHAFT
MiningEventConfig.ShowType.CURRENT -> islandType.isInIsland()
else -> true
}
@@ -67,40 +61,33 @@ object MiningEventDisplay {
}
}
- if (shouldShow) {
- val upcomingEvents = formatUpcomingEvents(eventDetails.islandEvents, eventDetails.lastEvent)
- val island =
- if (!config.islandAsIcon) Renderable.string("§a${islandType.displayName}§8:") else
- Renderable.horizontalContainer(
- listOf(
- when (islandType) {
- IslandType.DWARVEN_MINES -> Renderable.itemStack(
- "MITHRIL_ORE".asInternalName().getItemStack()
- )
-
- IslandType.CRYSTAL_HOLLOWS -> Renderable.itemStack(
- "PERFECT_RUBY_GEM".asInternalName().getItemStack()
- )
-
- IslandType.MINESHAFT -> Renderable.itemStack(ItemStack(Blocks.packed_ice))
- else -> unknownDisplay
- },
- Renderable.string("§8:")
- )
- )
- list.add(
- Renderable.horizontalContainer(
- listOf(
- island,
- *upcomingEvents
- ), 3
- )
- )
+ if (!shouldShow) continue
+ val upcomingEvents = formatUpcomingEvents(eventDetails.islandEvents, eventDetails.lastEvent)
+ val islandName = if (config.islandAsIcon) {
+ Renderable.horizontalContainer(getIslandIcon(islandType))
+ } else {
+ Renderable.string("§a${islandType.displayName}§8:")
}
+ add(Renderable.horizontalContainer(listOf(islandName, *upcomingEvents), 3))
}
- display = list
}
+ private fun getIslandIcon(islandType: IslandType) = listOf(
+ when (islandType) {
+ IslandType.DWARVEN_MINES -> Renderable.itemStack(
+ "MITHRIL_ORE".asInternalName().getItemStack(),
+ )
+
+ IslandType.CRYSTAL_HOLLOWS -> Renderable.itemStack(
+ "PERFECT_RUBY_GEM".asInternalName().getItemStack(),
+ )
+
+ else -> unknownDisplay
+ },
+ Renderable.string("§8:"),
+ )
+
+
private val unknownDisplay = Renderable.string("§7???")
private val transitionDisplay = Renderable.string("§8->")
@@ -118,14 +105,15 @@ object MiningEventDisplay {
}
fun updateData(eventData: MiningEventData) {
- eventData.runningEvents.forEach { (islandType, events) ->
+ for ((islandType, events) in eventData.runningEvents) {
+ // we now ignore mineshaft events.
+ if (islandType == IslandType.MINESHAFT) continue
val sorted = events.filter { islandType == IslandType.DWARVEN_MINES || !it.event.dwarvenSpecific }
.sortedBy { it.endsAt - it.event.defaultLength.inWholeMilliseconds }
val oldData = islandEventData[islandType]
if (oldData == null) {
- //todo remove once mineshaft is on main server
- if (sorted.isNotEmpty() || islandType != IslandType.MINESHAFT) {
+ if (sorted.isNotEmpty()) {
islandEventData[islandType] = MiningIslandEventInfo(sorted)
}
} else {
@@ -135,7 +123,7 @@ object MiningEventDisplay {
}
private fun shouldDisplay() =
- LorenzUtils.inSkyBlock && config.enabled && !(!config.outsideMining && !LorenzUtils.inAdvancedMiningIsland())
+ LorenzUtils.inSkyBlock && config.enabled && !(!config.outsideMining && !MiningEventTracker.isMiningIsland())
@SubscribeEvent
fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
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 44fc087c7..97806b6fb 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
@@ -73,7 +73,7 @@ object MiningEventTracker {
@SubscribeEvent
fun onBossbarChange(event: BossbarUpdateEvent) {
- if (!LorenzUtils.inAdvancedMiningIsland()) return
+ if (!isMiningIsland()) return
if (LorenzUtils.lastWorldSwitch.passedSince() < 5.seconds) return
if (!eventEndTime.isInPast()) {
return
@@ -89,7 +89,7 @@ object MiningEventTracker {
@SubscribeEvent
fun onChat(event: LorenzChatEvent) {
- if (!LorenzUtils.inAdvancedMiningIsland()) return
+ if (!isMiningIsland()) return
eventStartedPattern.matchMatcher(event.message) {
sendData(group("event"), null)
@@ -102,13 +102,15 @@ object MiningEventTracker {
@SubscribeEvent
fun onSecondPassed(event: SecondPassedEvent) {
if (!config.enabled) return
- if (!LorenzUtils.inSkyBlock || (!config.outsideMining && !LorenzUtils.inAdvancedMiningIsland())) return
+ if (!LorenzUtils.inSkyBlock || (!config.outsideMining && !isMiningIsland())) return
if (!canRequestAt.isInPast()) return
fetchData()
}
private fun sendData(eventName: String, time: String?) {
+ // we now ignore mineshaft events.
+ if (IslandType.MINESHAFT.isInIsland()) return
// TODO fix this via regex
if (eventName == "SLAYER QUEST") return
@@ -227,4 +229,7 @@ object MiningEventTracker {
if (element.asString == "BOTH") JsonPrimitive("ALL") else element
}
}
+
+ // ignoring mineshaft here is intentional
+ fun isMiningIsland() = IslandType.DWARVEN_MINES.isInIsland() || IslandType.CRYSTAL_HOLLOWS.isInIsland()
}