Skip to content

Commit

Permalink
V1.0.4 修复玩家退出清除Tick任务
Browse files Browse the repository at this point in the history
  • Loading branch information
YsGqHY committed Jan 26, 2024
1 parent 42bba5d commit 2d0ece3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group=kim.hhhhhy.regions
version=1.0.3
version=1.0.4
8 changes: 6 additions & 2 deletions src/main/kotlin/kim/hhhhhy/regions/data/AreaSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,18 @@ data class AreaSettings(
}
}

private fun startTick(player: Player, id: String) {
fun startTick(player: Player, id: String) {
val period = areasData[id]!!.tickPeriod
playerAreas[player.name to id] = submit(period = period) {
runTickAction(player, id)
}
}

private fun stopTick(player: Player, id: String) {
fun stopTick(player: Player, id: String? = null) {
if (id.isNullOrBlank()) {
playerAreas.filter { it.key.first == player.name }.forEach { it.value.cancel() }
return
}
playerAreas[player.name to id]?.cancel()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ object AreaListener {
@SubscribeEvent
fun onPlayerQuit(e: PlayerQuitEvent) {
playerSet.removeAll { it.first == e.player.name }
AreaSettings.stopTick(e.player)
}


Expand Down

0 comments on commit 2d0ece3

Please sign in to comment.