tab list: ignore invalid gamemodes

Some servers (like play.cubecraft.net) don't send a -1 gamemode. This produces a lot of exceptions and useless errors. Minecraft seems to handle that fine
This commit is contained in:
Bixilon 2022-05-07 22:10:08 +02:00
parent 3c61ee38ac
commit 145feaed42
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -43,7 +43,7 @@ class TabListS2CP(buffer: PlayInByteBuffer) : PlayS2CPacket {
TabListItemActions.ADD -> {
val name = buffer.readString()
val properties = buffer.readPlayerProperties()
val gamemode = Gamemodes[buffer.readVarInt()]
val gamemode = Gamemodes.getOrNull(buffer.readVarInt()) ?: Gamemodes.SURVIVAL
val ping = buffer.readVarInt()
val hasDisplayName = buffer.readBoolean()
val displayName = if (hasDisplayName) {