Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into hot-swappable-events
Browse files Browse the repository at this point in the history
  • Loading branch information
btwonion authored Aug 24, 2024
2 parents 7cf777d + 2479143 commit d119be1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/main/kotlin/dev/nyon/skylper/extensions/event/Events.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ data class CrystalFoundEvent(val crystal: Crystal) : InfoEvent
*/
data class CrystalPlaceEvent(val crystal: Crystal) : InfoEvent

/**
* Is invoked, when a crystal state is updated apart from place, found or run complete events.
*/
object CrystalStateUpdateEvent : InfoEvent

/**
* Is invoked, when player gains a Crystal Loot Bundle.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import dev.nyon.skylper.extensions.singleGroup
import dev.nyon.skylper.skyblock.models.Area
import dev.nyon.skylper.skyblock.models.mining.PowderType
import dev.nyon.skylper.skyblock.models.mining.crystalHollows.ChestReward
import dev.nyon.skylper.skyblock.tracker.mining.crystalHollows.powder.PowderGrindingTracker.data
import dev.nyon.skylper.skyblock.tracker.mining.crystalHollows.powder.PowderGrindingTracker.startTime
import kotlinx.datetime.Clock

object CrystalHollowsPowderGrindingApi {
Expand Down Expand Up @@ -36,7 +34,6 @@ object CrystalHollowsPowderGrindingApi {
val rewards = ChestReward.entries.associateWith { reward ->
val regex = reward.getRegex()
if (!regex.matches(rawText)) return@associateWith 0
if (startTime == null) startTime = now
val amount = regex.singleGroup(rawText)?.doubleOrNull()?.toInt() ?: return@associateWith 0
amount
}.toMutableMap().filter { it.value != 0 }
Expand All @@ -54,6 +51,6 @@ object CrystalHollowsPowderGrindingApi {
@SkylperEvent(area = Area.CRYSTAL_HOLLOWS)
fun bossBarListener(event: BossBarNameUpdate) {
if (!powderBossBarPattern.matches(event.rawText)) return
data.doublePowderActive = true
doublePowderActive = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ object HeartOfTheMountainApi {
else -> CrystalState.PLACED
}
}
EventHandler.invokeEvent(CrystalStateUpdateEvent)
}

name.matches(resetHotmRegex) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import net.minecraft.network.chat.Component
import kotlin.reflect.KClass

data class PowderGrindingData(
var doublePowderActive: Boolean = false,
var gemstone: ResourceData = ResourceData(),
var mithril: ResourceData = ResourceData(),
var chest: ResourceData = ResourceData()
Expand Down Expand Up @@ -76,7 +75,6 @@ data class PowderGrindingData(
override val resetTriggers: List<KClass<out Event<out Any>>> = listOf(LevelChangeEvent::class)

override fun reset() {
doublePowderActive = false
gemstone = ResourceData()
mithril = ResourceData()
chest = ResourceData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import dev.nyon.skylper.extensions.event.*
import dev.nyon.skylper.extensions.tracker.Tracker
import dev.nyon.skylper.independentScope
import dev.nyon.skylper.skyblock.data.api.CrystalHollowsLocationApi
import dev.nyon.skylper.skyblock.data.api.CrystalHollowsPowderGrindingApi
import dev.nyon.skylper.skyblock.models.mining.PowderType
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -79,7 +80,7 @@ object PowderGrindingTracker : Tracker<PowderGrindingData>("hollows.powder_grind
if (config.doublePowder) {
add(
finalComponent("double_powder",
Component.literal(if (data.doublePowderActive) Symbols.CHECK_MARK else Symbols.CROSS)
Component.literal(if (CrystalHollowsPowderGrindingApi.doublePowderActive) Symbols.CHECK_MARK else Symbols.CROSS)
.withStyle { it.withBold(true).withColor(ChatFormatting.WHITE) })
)
}
Expand Down

0 comments on commit d119be1

Please sign in to comment.