playtime관련 코드 삭제
This commit is contained in:
parent
511c84934a
commit
1d65bd0ac8
3 changed files with 2 additions and 44 deletions
|
|
@ -4,7 +4,6 @@ import com.beemer.essentials.data.Location
|
|||
import com.beemer.essentials.data.Player
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.time.Duration
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeParseException
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
|
@ -52,7 +51,6 @@ object PlayerConfig {
|
|||
} catch (_: DateTimeParseException) {
|
||||
firstJoin
|
||||
}
|
||||
val playTime = tag.getLong("playTime")
|
||||
val lastLocation =
|
||||
if (tag.contains("lastLocation")) {
|
||||
val loc = tag.getCompound("lastLocation")
|
||||
|
|
@ -65,7 +63,7 @@ object PlayerConfig {
|
|||
)
|
||||
} else null
|
||||
|
||||
players[uuid] = Player(name, firstJoin, lastJoin, playTime, lastLocation)
|
||||
players[uuid] = Player(name, firstJoin, lastJoin, lastLocation)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
|
@ -84,7 +82,6 @@ object PlayerConfig {
|
|||
putString("name", info.name)
|
||||
putString("firstJoin", info.firstJoin.toString())
|
||||
putString("lastJoin", info.lastJoin.toString())
|
||||
putLong("playTime", info.playTime)
|
||||
info.lastLocation?.let { loc ->
|
||||
val locTag =
|
||||
CompoundTag().apply {
|
||||
|
|
@ -110,13 +107,7 @@ object PlayerConfig {
|
|||
val now = LocalDateTime.now()
|
||||
return players.compute(uuid) { _, existing ->
|
||||
if (existing == null) {
|
||||
Player(
|
||||
name = currentName,
|
||||
firstJoin = now,
|
||||
lastJoin = now,
|
||||
playTime = 0,
|
||||
lastLocation = null
|
||||
)
|
||||
Player(name = currentName, firstJoin = now, lastJoin = now, lastLocation = null)
|
||||
} else {
|
||||
if (existing.name != currentName) existing.name = currentName
|
||||
existing
|
||||
|
|
@ -136,10 +127,6 @@ object PlayerConfig {
|
|||
val uuid = player.uuid.toString()
|
||||
val now = LocalDateTime.now()
|
||||
val info = players[uuid] ?: return
|
||||
val delta = Duration.between(info.lastJoin, now).toMillis()
|
||||
if (delta > 0) {
|
||||
info.playTime += delta
|
||||
}
|
||||
info.lastJoin = now
|
||||
saveConfig()
|
||||
}
|
||||
|
|
@ -155,12 +142,4 @@ object PlayerConfig {
|
|||
val uuid = player.uuid.toString()
|
||||
return players[uuid]
|
||||
}
|
||||
|
||||
fun getAccumulatedPlayTime(player: ServerPlayer): Long {
|
||||
val uuid = player.uuid.toString()
|
||||
val info = players[uuid] ?: return 0L
|
||||
val now = LocalDateTime.now()
|
||||
val extra = Duration.between(info.lastJoin, now).toMillis().coerceAtLeast(0)
|
||||
return info.playTime + extra
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,5 @@ data class Player(
|
|||
var name: String,
|
||||
val firstJoin: LocalDateTime,
|
||||
var lastJoin: LocalDateTime,
|
||||
var playTime: Long,
|
||||
var lastLocation: Location? = null
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
package com.beemer.essentials.util
|
||||
|
||||
object TimeUtils {
|
||||
fun formatPlayTimeMillis(ms: Long): String {
|
||||
var seconds = ms / 1000
|
||||
val days = seconds / (24 * 3600)
|
||||
seconds %= (24 * 3600)
|
||||
val hours = seconds / 3600
|
||||
seconds %= 3600
|
||||
val minutes = seconds / 60
|
||||
seconds %= 60
|
||||
|
||||
return buildString {
|
||||
if (days > 0) append("${days}일 ")
|
||||
if (hours > 0) append("${hours}시간 ")
|
||||
if (minutes > 0 || hours > 0 || days > 0) append("${minutes}분 ")
|
||||
append("${seconds}초")
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue