21w19a+: Respond to ping packets, fix eventually task abortion in ThreadPool

This commit is contained in:
Bixilon 2021-05-23 14:51:56 +02:00
parent 08951f7b1c
commit 142d55b7fd
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
3 changed files with 9 additions and 2 deletions

View File

@ -191,7 +191,7 @@ class LeftClickHandler(
speedMultiplier *= 0.3f.pow(it.amplifier + 1)
}
// ToDp: Check if is in water
// ToDo: Check if is in water
if (!connection.player.entity.onGround) {
speedMultiplier /= 5.0f

View File

@ -13,6 +13,8 @@
package de.bixilon.minosoft.protocol.packets.s2c.play
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
import de.bixilon.minosoft.protocol.packets.c2s.play.PongC2SP
import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
import de.bixilon.minosoft.util.logging.Log
@ -22,6 +24,11 @@ import de.bixilon.minosoft.util.logging.LogMessageType
class PingS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket() {
val id = buffer.readInt()
override fun handle(connection: PlayConnection) {
connection.sendPacket(PongC2SP(id))
}
override fun log() {
Log.log(LogMessageType.NETWORK_PACKETS_IN, LogLevels.VERBOSE) { "Ping (id=$id)" }
}

View File

@ -43,10 +43,10 @@ class ThreadPool(
try {
availableThreads += Thread.currentThread()
Thread.sleep(Long.MAX_VALUE)
availableThreads -= Thread.currentThread()
} catch (exception: InterruptedException) {
// Log.log(LogMessageType.OTHER, LogLevels.VERBOSE) { "Thread (${Thread.currentThread()} sleeping got interrupted" }
}
availableThreads -= Thread.currentThread()
}
for (i in 0 until threadCount - threads.size) {