Skip to content

Commit 0488844

Browse files
committed
fix: spooky festival not working
Signed-off-by: J10a1n15 <[email protected]>
1 parent 271f41d commit 0488844

File tree

1 file changed

+35
-11
lines changed
  • src/main/kotlin/me/owdding/customscoreboard/feature/customscoreboard/events

1 file changed

+35
-11
lines changed
Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,51 @@
11
package me.owdding.customscoreboard.feature.customscoreboard.events
22

33
import me.owdding.customscoreboard.AutoElement
4-
import me.owdding.customscoreboard.utils.TextUtils.anyMatch
4+
import me.owdding.customscoreboard.utils.NumberUtils.format
55
import net.minecraft.network.chat.Component
6+
import tech.thatgravyboat.skyblockapi.api.area.hub.SpookyFestivalAPI
67
import tech.thatgravyboat.skyblockapi.api.events.info.ScoreboardUpdateEvent
7-
import tech.thatgravyboat.skyblockapi.api.location.SkyBlockIsland
8-
import tech.thatgravyboat.skyblockapi.utils.regex.component.ComponentRegex
9-
import tech.thatgravyboat.skyblockapi.utils.regex.component.anyMatch
8+
import tech.thatgravyboat.skyblockapi.utils.text.Text
9+
import tech.thatgravyboat.skyblockapi.utils.text.TextBuilder.append
10+
import tech.thatgravyboat.skyblockapi.utils.text.TextColor
11+
import tech.thatgravyboat.skyblockapi.utils.text.TextStyle.color
1012

1113
@AutoElement
1214
object EventSpooky : Event() {
13-
override fun getDisplay() = formattedLine
14-
15-
override fun showIsland() = SkyBlockIsland.inAnyIsland(SkyBlockIsland.PRIVATE_ISLAND, SkyBlockIsland.GARDEN)
15+
override fun getDisplay() = formattedLines
1616

1717
override val configLine = "Spooky"
1818

1919

20-
private var formattedLine: Component? = null
21-
22-
private val festivalRegex = ComponentRegex("Spooky Festival [\\d.,:]+")
20+
private var formattedLines: List<Component> = emptyList()
2321

2422
override fun onScoreboardUpdate(event: ScoreboardUpdateEvent) {
25-
formattedLine = event.components.find(festivalRegex::matches)
23+
if (SpookyFestivalAPI.onGoing) {
24+
formattedLines = listOf(
25+
Text.of("Spooky Festival ") {
26+
color = TextColor.ORANGE
27+
append(getTime(), TextColor.WHITE)
28+
},
29+
Text.of("Your Candy:", TextColor.GRAY),
30+
getCandy(),
31+
)
32+
} else formattedLines = emptyList()
33+
}
34+
35+
private fun getTime(): String {
36+
val totalSeconds = SpookyFestivalAPI.duration.inWholeSeconds
37+
val minutes = totalSeconds / 60
38+
val seconds = totalSeconds % 60
39+
return "%02d:%02d".format(minutes, seconds)
40+
}
41+
42+
private fun getCandy() = Text.of {
43+
color = TextColor.GRAY
44+
append("${SpookyFestivalAPI.greenCandy.format()} Green", TextColor.GREEN)
45+
append(", ")
46+
append("${SpookyFestivalAPI.purpleCandy.format()} Purple", TextColor.DARK_PURPLE)
47+
append(" (")
48+
append(SpookyFestivalAPI.points.format(), TextColor.ORANGE)
49+
append(" pts.)")
2650
}
2751
}

0 commit comments

Comments
 (0)