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.
This commit is contained in:
Jadon Fowler 2016-08-23 20:18:41 -07:00
parent 8b1b94cb7c
commit 27baf233c9
No known key found for this signature in database
GPG key ID: B98B526268287A29

View file

@ -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: