chat message: set sender to null if uuid is 0

This commit is contained in:
Bixilon 2022-12-14 17:59:58 +01:00
parent 1ec4fda1bd
commit 14588f55c4
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 3 additions and 1 deletions

View File

@ -26,6 +26,7 @@ import de.bixilon.minosoft.protocol.packets.s2c.PlayS2CPacket
import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer import de.bixilon.minosoft.protocol.protocol.PlayInByteBuffer
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
import de.bixilon.minosoft.protocol.protocol.ProtocolVersions import de.bixilon.minosoft.protocol.protocol.ProtocolVersions
import de.bixilon.minosoft.util.KUtil
import de.bixilon.minosoft.util.logging.Log import de.bixilon.minosoft.util.logging.Log
import de.bixilon.minosoft.util.logging.LogLevels import de.bixilon.minosoft.util.logging.LogLevels
import de.bixilon.minosoft.util.logging.LogMessageType import de.bixilon.minosoft.util.logging.LogMessageType
@ -58,7 +59,7 @@ class ChatMessageS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
override fun handle(connection: PlayConnection) { override fun handle(connection: PlayConnection) {
val type = if (overlay) connection.registries.messageTypeRegistry[DefaultMessageTypes.GAME]!! else type val type = if (overlay) connection.registries.messageTypeRegistry[DefaultMessageTypes.GAME]!! else type
val sender = sender val sender = sender
val message: ChatMessage = if (sender == null) { val message: ChatMessage = if (sender == null || sender == KUtil.NULL_UUID) {
SimpleChatMessage(text, type) SimpleChatMessage(text, type)
} else { } else {
PlayerChatMessage(text, type, connection.getMessageSender(sender)) PlayerChatMessage(text, type, connection.getMessageSender(sender))

View File

@ -57,6 +57,7 @@ import javax.net.ssl.SSLContext
object KUtil { object KUtil {
val NULL_UUID = UUID(0L, 0L)
val RANDOM = Random() val RANDOM = Random()
val EMPTY_BYTE_ARRAY = ByteArray(0) val EMPTY_BYTE_ARRAY = ByteArray(0)