This repository has been archived by the owner on Nov 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
375 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
## Features | ||
- update powders from tablist more often | ||
- rework powder calculation for powder grinding widget | ||
- use better prefix for chat messages | ||
- add event forecast widget for dwarves, crystals and mineshafts | ||
|
||
## Bug Fixes | ||
- disable delete button of waypoint on deletion in location screen | ||
none | ||
|
||
## Technical changes | ||
- update to konfig 2.0.2 | ||
- rework event api to be hot-swappable | ||
- redo all calculations to apis | ||
none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/kotlin/dev/nyon/skylper/skyblock/data/api/MiningEventApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package dev.nyon.skylper.skyblock.data.api | ||
|
||
import dev.nyon.skylper.extensions.httpClient | ||
import dev.nyon.skylper.extensions.json | ||
import dev.nyon.skylper.independentScope | ||
import dev.nyon.skylper.skyblock.data.session.PlayerSessionData | ||
import dev.nyon.skylper.skyblock.models.mining.SoopyEvent | ||
import io.ktor.client.request.* | ||
import io.ktor.client.statement.* | ||
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.launch | ||
import kotlin.time.Duration.Companion.seconds | ||
|
||
object MiningEventApi { | ||
private var soopyEventData: SoopyEvent? = null | ||
val currentEvents: List<SoopyEvent.MiningEvent> | ||
get() = soopyEventData?.data?.runningEvents?.get(PlayerSessionData.currentArea) ?: emptyList() | ||
|
||
@Suppress("unused") | ||
private val updater = independentScope.launch { | ||
while (true) { | ||
val soopyEvent = runCatching { | ||
val response = httpClient.get("https://api.soopy.dev/skyblock/chevents/get").bodyAsText() | ||
json.decodeFromString<SoopyEvent>(response) | ||
}.onFailure { it.printStackTrace() }.getOrNull() | ||
soopyEventData = soopyEvent | ||
delay(45.seconds) | ||
} | ||
} | ||
} |
5 changes: 3 additions & 2 deletions
5
src/main/kotlin/dev/nyon/skylper/skyblock/data/online/IslandGroups.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,19 @@ | ||
package dev.nyon.skylper.skyblock.data.online | ||
|
||
import dev.nyon.skylper.skyblock.models.Area | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
object IslandGroups : OnlineData<IslandGroupsData>(IslandGroupsData::class) { | ||
override val url: String = SKYLPER_REPO_URL | ||
override val path: String = "island_groups.json" | ||
|
||
var groups: IslandGroupsData = IslandGroupsData(listOf()) | ||
var groups: IslandGroupsData = IslandGroupsData(listOf(), listOf()) | ||
|
||
override fun setData(data: IslandGroupsData?) { | ||
groups = data ?: return | ||
} | ||
} | ||
|
||
@Serializable | ||
data class IslandGroupsData(val mining: List<Area>) | ||
data class IslandGroupsData(val mining: List<Area>, @SerialName("mining_events") val miningEvents: List<Area>) |
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/dev/nyon/skylper/skyblock/models/mining/MiningEventType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package dev.nyon.skylper.skyblock.models.mining | ||
|
||
import kotlinx.serialization.Serializable | ||
import net.minecraft.ChatFormatting | ||
import net.minecraft.network.chat.Component | ||
|
||
@Serializable | ||
enum class MiningEventType(private val colorChar: Char) { | ||
GONE_WITH_THE_WIND('9'), | ||
BETTER_TOGETHER('d'), | ||
DOUBLE_POWDER('b'), | ||
RAFFLE('6'), | ||
GOBLIN_RAID('c'), | ||
MITHRIL_GOURMAND('b'); | ||
|
||
fun getDisplayName(): Component { | ||
return Component.literal(name.replace("_", " ")).withStyle(ChatFormatting.getByCode(colorChar)!!) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/kotlin/dev/nyon/skylper/skyblock/models/mining/SoopyEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package dev.nyon.skylper.skyblock.models.mining | ||
|
||
import dev.nyon.skylper.extensions.InstantMillisSerializer | ||
import dev.nyon.skylper.skyblock.models.Area | ||
import kotlinx.datetime.Instant | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class SoopyEvent(val success: Boolean, val data: Data) { | ||
@Serializable | ||
data class Data( | ||
@SerialName("running_events") | ||
val runningEvents: Map<Area, List<MiningEvent>> | ||
) | ||
|
||
@Serializable | ||
data class MiningEvent( | ||
val event: MiningEventType, | ||
@SerialName("ends_at") | ||
val endsAt: @Serializable(with = InstantMillisSerializer::class) Instant, | ||
@SerialName("lobby_count") | ||
val lobbyCount: Int | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/main/kotlin/dev/nyon/skylper/skyblock/render/mining/MiningEventWidget.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package dev.nyon.skylper.skyblock.render.mining | ||
|
||
import dev.nyon.skylper.config.config | ||
import dev.nyon.skylper.extensions.math.toPrettyString | ||
import dev.nyon.skylper.extensions.render.hud.TableHudWidget | ||
import dev.nyon.skylper.extensions.render.hud.components.PlainTextHudComponent | ||
import dev.nyon.skylper.skyblock.data.api.MiningEventApi | ||
import dev.nyon.skylper.skyblock.data.online.IslandGroups | ||
import dev.nyon.skylper.skyblock.data.session.PlayerSessionData | ||
import kotlinx.datetime.Clock | ||
import net.minecraft.network.chat.Component | ||
|
||
object MiningEventWidget : TableHudWidget(Component.translatable("menu.skylper.overlay.mining.events.title"), 1, 3) { | ||
override var x: Double = config.mining.eventOverlay.x.toDouble() | ||
set(value) { | ||
config.mining.eventOverlay.x = value.toInt() | ||
field = value | ||
} | ||
override var y: Double = config.mining.eventOverlay.x.toDouble() | ||
set(value) { | ||
config.mining.eventOverlay.x = value.toInt() | ||
field = value | ||
} | ||
|
||
override fun update() { | ||
super.update() | ||
val data = MiningEventApi.currentEvents | ||
|
||
rows = data.size | ||
data.forEachIndexed { index, event -> | ||
addComponent(index, 0, PlainTextHudComponent(event.event.getDisplayName())) | ||
val remaining = event.endsAt - Clock.System.now() | ||
addComponent( | ||
index, | ||
1, | ||
PlainTextHudComponent( | ||
Component.translatable( | ||
"menu.skylper.overlay.mining.events.ends_in", | ||
remaining.toPrettyString() | ||
) | ||
) | ||
) | ||
addComponent( | ||
index, | ||
2, | ||
PlainTextHudComponent( | ||
Component.translatable( | ||
"menu.skylper.overlay.mining.events.lobby_count.${if (event.lobbyCount == 1) "single" else "multiple"}", | ||
event.lobbyCount | ||
) | ||
) | ||
) | ||
} | ||
} | ||
|
||
override fun shouldRender(): Boolean { | ||
return IslandGroups.groups.miningEvents.contains(PlayerSessionData.currentArea) && config.mining.eventOverlay.enabled | ||
} | ||
|
||
init { | ||
init() | ||
} | ||
} |
Oops, something went wrong.