From 27baf233c98a31834b8d3ba28d020cc99455686f Mon Sep 17 00:00:00 2001 From: Jadon Fowler Date: Tue, 23 Aug 2016 20:18:41 -0700 Subject: [PATCH] Check for negative GameModes in ServerPlayerListEntryPacket These are sometimes negative for some reason. I was only able to reproduce this on one server, but this fixed it. The server was sending out a GameMode of -1. --- .../packet/ingame/server/ServerPlayerListEntryPacket.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerPlayerListEntryPacket.java b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerPlayerListEntryPacket.java index 8955474c..03d8b48e 100644 --- a/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerPlayerListEntryPacket.java +++ b/src/main/java/org/spacehq/mc/protocol/packet/ingame/server/ServerPlayerListEntryPacket.java @@ -63,7 +63,8 @@ public class ServerPlayerListEntryPacket implements Packet { profile.getProperties().add(new GameProfile.Property(propertyName, value, signature)); } - GameMode gameMode = MagicValues.key(GameMode.class, in.readVarInt()); + int g = in.readVarInt(); + GameMode gameMode = MagicValues.key(GameMode.class, g < 0 ? 0 : g); int ping = in.readVarInt(); Message displayName = null; if(in.readBoolean()) { @@ -73,7 +74,8 @@ public class ServerPlayerListEntryPacket implements Packet { entry = new PlayerListEntry(profile, gameMode, ping, displayName); break; case UPDATE_GAMEMODE: - GameMode mode = MagicValues.key(GameMode.class, in.readVarInt()); + g = in.readVarInt(); + GameMode mode = MagicValues.key(GameMode.class, g < 0 ? 0 : g); entry = new PlayerListEntry(profile, mode); break; case UPDATE_LATENCY: