feat: slow down PSH mutex checks

This commit is contained in:
xtex 2023-07-26 16:46:50 +08:00
parent fa16d2172f
commit 30187548bb
Signed by: xtex
GPG Key ID: B918086ED8045B91

View File

@ -12,12 +12,14 @@ object ProjectionShellMutex {
init { init {
TickEvent.SERVER_POST.register { server -> TickEvent.SERVER_POST.register { server ->
val mutex = (server as ProjectionShellMutexAccessor).`quaedam$getProjectionShellMutex`() if (server.tickCount and 8 == 0) {
val currentTime = System.currentTimeMillis() val mutex = (server as ProjectionShellMutexAccessor).`quaedam$getProjectionShellMutex`()
mutex.forEach { (pos, lock) -> val currentTime = System.currentTimeMillis()
if (currentTime - lock.time > 60 * 1000) { mutex.forEach { (pos, lock) ->
mutex.remove(pos) if (currentTime - lock.time > 60 * 1000) {
ProjectionShell.channel.sendToPlayer(lock.player, ClientboundPSHLockRevokePacket) mutex.remove(pos)
ProjectionShell.channel.sendToPlayer(lock.player, ClientboundPSHLockRevokePacket)
}
} }
} }
} }