File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed
src/main/kotlin/xyz/xasmc/hashbook Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import org.bukkit.block.ChiseledBookshelf
5
5
import org.bukkit.event.EventHandler
6
6
import org.bukkit.event.Listener
7
7
import org.bukkit.event.player.PlayerMoveEvent
8
+ import org.bukkit.event.player.PlayerQuitEvent
8
9
import org.bukkit.inventory.meta.BookMeta
9
10
import org.bukkit.inventory.meta.BookMeta.Generation.*
10
11
import xyz.xasmc.hashbook.util.MarkUtil
@@ -58,4 +59,9 @@ class BookshelfListener : Listener {
58
59
}
59
60
MarkUtil .updateMark(player, markLocation.toLocation(world), nameSb.toString())
60
61
}
62
+
63
+ @EventHandler
64
+ fun onPlayerQuit (event : PlayerQuitEvent ) {
65
+ MarkUtil .removeMark(event.player)
66
+ }
61
67
}
Original file line number Diff line number Diff line change @@ -17,15 +17,12 @@ object MarkUtil {
17
17
val count = textList.size
18
18
val interval = 0.2
19
19
val offset = - 0.4
20
-
21
20
val marks = playerMark[player] ? : mutableListOf<ArmorStand >().also { playerMark[player] = it }
22
-
23
21
val currentCount = marks.size
24
22
when {
25
23
count > currentCount -> repeat(count - currentCount) { marks.add(createArmorStand(world)) }
26
24
count < currentCount -> repeat(currentCount - count) { marks.removeLast()?.remove() }
27
25
}
28
-
29
26
val top = location.clone().add(0.0 , interval * count / 2 + offset, 0.0 )
30
27
textList.forEachIndexed { i, it ->
31
28
val mark = playerMark[player]!! [i]
You can’t perform that action at this time.
0 commit comments