blob: 77daa26011a229079603d9099fa097e8b0e12774 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.events.BossbarUpdateEvent
import at.hannibal2.skyhanni.events.LorenzTickEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
import net.minecraft.entity.boss.BossStatus
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@SkyHanniModule
object BossbarData {
private var bossbar: String? = null
private var previousServerBossbar = ""
fun getBossbar() = bossbar ?: ""
@SubscribeEvent
fun onWorldChange(event: LorenzWorldChangeEvent) {
val oldBossbar = bossbar ?: return
previousServerBossbar = oldBossbar
bossbar = null
}
@SubscribeEvent
fun onTick(event: LorenzTickEvent) {
val bossbarLine = BossStatus.bossName ?: return
if (bossbarLine.isBlank() || bossbarLine.isEmpty()) return
if (bossbarLine == bossbar) return
if (bossbarLine == previousServerBossbar) return
if (previousServerBossbar.isNotEmpty()) previousServerBossbar = ""
bossbar = bossbarLine
BossbarUpdateEvent(bossbarLine).postAndCatch()
}
}
|