Use GameProfile.setProperties in ServerPlayerListEntryPacket.

This commit is contained in:
Steveice10 2020-04-23 10:45:35 -07:00
parent 4058738103
commit f1efbed86c

View file

@ -17,6 +17,8 @@ import lombok.NonNull;
import lombok.Setter; import lombok.Setter;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID; import java.util.UUID;
@Data @Data
@ -42,8 +44,9 @@ public class ServerPlayerListEntryPacket implements Packet {
PlayerListEntry entry = null; PlayerListEntry entry = null;
switch(this.action) { switch(this.action) {
case ADD_PLAYER: case ADD_PLAYER: {
int properties = in.readVarInt(); int properties = in.readVarInt();
List<GameProfile.Property> propertyList = new ArrayList<>();
for(int index = 0; index < properties; index++) { for(int index = 0; index < properties; index++) {
String propertyName = in.readString(); String propertyName = in.readString();
String value = in.readString(); String value = in.readString();
@ -52,11 +55,13 @@ public class ServerPlayerListEntryPacket implements Packet {
signature = in.readString(); signature = in.readString();
} }
profile.getProperties().add(new GameProfile.Property(propertyName, value, signature)); propertyList.add(new GameProfile.Property(propertyName, value, signature));
} }
int g = in.readVarInt(); profile.setProperties(propertyList);
GameMode gameMode = MagicValues.key(GameMode.class, g < 0 ? 0 : g);
int rawGameMode = in.readVarInt();
GameMode gameMode = MagicValues.key(GameMode.class, rawGameMode < 0 ? 0 : rawGameMode);
int ping = in.readVarInt(); int ping = in.readVarInt();
Message displayName = null; Message displayName = null;
if(in.readBoolean()) { if(in.readBoolean()) {
@ -65,23 +70,29 @@ public class ServerPlayerListEntryPacket implements Packet {
entry = new PlayerListEntry(profile, gameMode, ping, displayName); entry = new PlayerListEntry(profile, gameMode, ping, displayName);
break; break;
case UPDATE_GAMEMODE: }
g = in.readVarInt(); case UPDATE_GAMEMODE: {
GameMode mode = MagicValues.key(GameMode.class, g < 0 ? 0 : g); int rawGameMode = in.readVarInt();
GameMode mode = MagicValues.key(GameMode.class, rawGameMode < 0 ? 0 : rawGameMode);
entry = new PlayerListEntry(profile, mode); entry = new PlayerListEntry(profile, mode);
break; break;
case UPDATE_LATENCY: }
int png = in.readVarInt(); case UPDATE_LATENCY: {
entry = new PlayerListEntry(profile, png); int ping = in.readVarInt();
entry = new PlayerListEntry(profile, ping);
break; break;
case UPDATE_DISPLAY_NAME: }
Message disp = null; case UPDATE_DISPLAY_NAME: {
Message displayName = null;
if(in.readBoolean()) { if(in.readBoolean()) {
disp = Message.fromString(in.readString()); displayName = Message.fromString(in.readString());
} }
entry = new PlayerListEntry(profile, disp); entry = new PlayerListEntry(profile, displayName);
break; break;
}
case REMOVE_PLAYER: case REMOVE_PLAYER:
entry = new PlayerListEntry(profile); entry = new PlayerListEntry(profile);
break; break;