Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit f4e47bd

Browse files
authored
Merge pull request #146 from DockyardMC/fix/bossbar-memory-leak
Fix bossbar not removing viewers when they leave
2 parents ea6002e + 3cf68a6 commit f4e47bd

File tree

1 file changed

+6
-0
lines changed
  • src/main/kotlin/io/github/dockyardmc/apis/bossbar

1 file changed

+6
-0
lines changed

src/main/kotlin/io/github/dockyardmc/apis/bossbar/Bossbar.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package io.github.dockyardmc.apis.bossbar
22

33
import cz.lukynka.bindables.Bindable
44
import io.github.dockyardmc.events.EventPool
5+
import io.github.dockyardmc.events.PlayerLeaveEvent
56
import io.github.dockyardmc.extentions.sendPacket
67
import io.github.dockyardmc.player.Player
78
import io.github.dockyardmc.protocol.packets.play.clientbound.BossbarPacketAction
@@ -40,6 +41,11 @@ class Bossbar(
4041
progress.valueChanged { viewers.sendPacket(ClientboundBossbarPacket(BossbarPacketAction.UPDATE_HEALTH, this)) }
4142
color.valueChanged { viewers.sendPacket(ClientboundBossbarPacket(BossbarPacketAction.UPDATE_STYLE, this)) }
4243
notches.valueChanged { viewers.sendPacket(ClientboundBossbarPacket(BossbarPacketAction.UPDATE_STYLE, this)) }
44+
45+
eventPool.on<PlayerLeaveEvent> { event ->
46+
if(!viewers.contains(event.player)) return@on
47+
removeViewer(event.player)
48+
}
4349
}
4450

4551
override fun dispose() {

0 commit comments

Comments
 (0)