Skip to content

Commit 8ae96cb

Browse files
committed
🐛 fix player quit
1 parent a137057 commit 8ae96cb

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/main/kotlin/xyz/xasmc/hashbook/listener/BookshelfListener.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import org.bukkit.block.ChiseledBookshelf
55
import org.bukkit.event.EventHandler
66
import org.bukkit.event.Listener
77
import org.bukkit.event.player.PlayerMoveEvent
8+
import org.bukkit.event.player.PlayerQuitEvent
89
import org.bukkit.inventory.meta.BookMeta
910
import org.bukkit.inventory.meta.BookMeta.Generation.*
1011
import xyz.xasmc.hashbook.util.MarkUtil
@@ -58,4 +59,9 @@ class BookshelfListener : Listener {
5859
}
5960
MarkUtil.updateMark(player, markLocation.toLocation(world), nameSb.toString())
6061
}
62+
63+
@EventHandler
64+
fun onPlayerQuit(event: PlayerQuitEvent) {
65+
MarkUtil.removeMark(event.player)
66+
}
6167
}

src/main/kotlin/xyz/xasmc/hashbook/util/MarkUtil.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,12 @@ object MarkUtil {
1717
val count = textList.size
1818
val interval = 0.2
1919
val offset = -0.4
20-
2120
val marks = playerMark[player] ?: mutableListOf<ArmorStand>().also { playerMark[player] = it }
22-
2321
val currentCount = marks.size
2422
when {
2523
count > currentCount -> repeat(count - currentCount) { marks.add(createArmorStand(world)) }
2624
count < currentCount -> repeat(currentCount - count) { marks.removeLast()?.remove() }
2725
}
28-
2926
val top = location.clone().add(0.0, interval * count / 2 + offset, 0.0)
3027
textList.forEachIndexed { i, it ->
3128
val mark = playerMark[player]!![i]

0 commit comments

Comments
 (0)