aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/mining
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-06-13 19:40:24 +0200
committerGitHub <noreply@github.com>2024-06-13 19:40:24 +0200
commita9e80dface675c7bf5e5666d53e7f463071f3c29 (patch)
tree60258df3cdc54c0bd8b266116a08c77d913553d8 /src/main/java/at/hannibal2/skyhanni/features/mining
parent38ad085118f6d0403c8d59345a250dd182191a20 (diff)
downloadskyhanni-a9e80dface675c7bf5e5666d53e7f463071f3c29.tar.gz
skyhanni-a9e80dface675c7bf5e5666d53e7f463071f3c29.tar.bz2
skyhanni-a9e80dface675c7bf5e5666d53e7f463071f3c29.zip
Removal: Removed mineshaft from mining event display. (#2083)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/mining')
-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
2 files changed, 42 insertions, 49 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 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()
}