Skip to content

Commit

Permalink
Add Elderpork (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oxyopiia committed Aug 12, 2024
1 parent db53a8a commit 3ef47d8
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/main/java/net/oxyopia/vice/config/features/BossStorage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class BossStorage {
@Expose
val minehut = Boss()

@Expose
val elderpork = Boss()

@Expose
val shadowGelato = Boss()

Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/oxyopia/vice/data/World.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ enum class World(val id: String, val displayName: String, val type: WorldType =
AbyssalVice("darkvice", "Abyssal Vice", type = WorldType.BOSS),
ShadowGelato("shadowgelato", "Shadow Gelato", type = WorldType.BOSS),
Diox("dioxarena", "Diox", type = WorldType.BOSS),
Elderpork("elderpork", "Elderpork", type = WorldType.BOSS),

Floor2Arena("f2arenas", "Void Voyage", type = WorldType.ARENA, displayColor = Colors.ChatColor.Green),
Floor3Arena("f3arenas", "Cryonic Caverns", type = WorldType.ARENA, displayColor = Colors.ChatColor.Blue),
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/net/oxyopia/vice/events/ChatEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ class ChatEvent(content: Text) : ViceEvent.Cancelable<Boolean>() {
val string: String = content.string

val sender: String by lazy {
string.substringBefore(":").substringAfterLast(" ")
string.substringBefore(":", "@Vice-NO_SENDER@").substringAfterLast(" ")
}

val hasNoSender by lazy {
sender == "@Vice-NO_SENDER@"
}

override fun cancel() {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/net/oxyopia/vice/features/bosses/BossCounter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ object BossCounter: HudElement("Boss Counter", Vice.storage.bosses.bossCounterPo
list.addBossStat("El Gelato", Colors.ChatColor.Green, bosses.gelato.completions)
list.addBossStat("PPP", Colors.ChatColor.Red, bosses.ppp.completions)
list.addBossStat("Minehut", Colors.ChatColor.Aqua, bosses.minehut.completions)
list.addBossStat("Elderpork", Colors.Elderpork, bosses.elderpork.completions)
list.addBossStat("Shadow Gelato", Colors.ShadowGelato, bosses.shadowGelato.completions)
list.addBossStat("Abyssal Vice", Colors.Diox, bosses.abyssalVice.completions)

Expand All @@ -51,6 +52,7 @@ object BossCounter: HudElement("Boss Counter", Vice.storage.bosses.bossCounterPo
@SubscribeEvent
fun onChatMessage(event: ChatEvent) {
val content = event.string
if (!event.hasNoSender) return

when {
World.Vice.isInWorld() && content.contains(viceTimeRegex) -> bosses.vice.completions--
Expand All @@ -59,6 +61,7 @@ object BossCounter: HudElement("Boss Counter", Vice.storage.bosses.bossCounterPo
World.Minehut.isInWorld() && content.contains(minehutTimeRegex) -> bosses.minehut.completions--
World.ShadowGelato.isInWorld() && content.contains(shadowTimeRegex) -> bosses.shadowGelato.completions--
World.AbyssalVice.isInWorld() && content.contains(abyssalCompletionRegex) -> bosses.abyssalVice.completions++
World.Elderpork.isInWorld() && content.contains("TAPE FINISHED.") -> bosses.elderpork.completions++
else -> return
}

Expand Down
45 changes: 45 additions & 0 deletions src/main/java/net/oxyopia/vice/features/bosses/Elderpork.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package net.oxyopia.vice.features.bosses

import net.minecraft.entity.boss.BossBar
import net.oxyopia.vice.data.Colors
import net.oxyopia.vice.data.World
import net.oxyopia.vice.events.BossBarEvents
import net.oxyopia.vice.events.ChatEvent
import net.oxyopia.vice.events.core.SubscribeEvent
import net.oxyopia.vice.utils.HudUtils.toText
import net.oxyopia.vice.utils.TimeUtils.formatTimer
import net.oxyopia.vice.utils.TimeUtils.timeDelta
import net.oxyopia.vice.utils.TimeUtils.timeDeltaWithin
import kotlin.time.Duration.Companion.seconds

object Elderpork : Boss(
World.Elderpork,
Regex("Elderpork the Great - (?:(\\d+)/\\d+|YOU/SHOULD/KILL/YOURSELF) ❤ \\[PHASE (\\d+)]"),
phaseTimesSec = listOf(60 * 2, 60 * 10, 60 * 5, 60 * 2)
){
private val MONITOR_MAX_TIME = 30.seconds

private var monitorLastStart = -0L

@SubscribeEvent
fun onChatMessage(event: ChatEvent) {
if (event.string.endsWith("is preparing to fight Elderpork the Great!") && event.hasNoSender) {
monitorLastStart = System.currentTimeMillis()
}
}

@SubscribeEvent
fun onBossbarAfter(event: BossBarEvents.Insert) {
if (monitorLastStart.timeDeltaWithin(MONITOR_MAX_TIME)) {
val elapsedTime = monitorLastStart.timeDelta()
val percentageComplete = elapsedTime / MONITOR_MAX_TIME

event.add(
"Delivery Start ${elapsedTime.formatTimer(MONITOR_MAX_TIME)}".toText(Colors.Elderpork),
1f - percentageComplete.toFloat(),
BossBar.Color.PINK,
BossBar.Style.NOTCHED_10
)
}
}
}

0 comments on commit 3ef47d8

Please sign in to comment.