2022-04-17 12:43:07 +00:00
|
|
|
package emu.grasscutter.server.packet.send;
|
|
|
|
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
import emu.grasscutter.game.avatar.Avatar;
|
2022-04-27 04:24:25 +00:00
|
|
|
import emu.grasscutter.game.player.Player;
|
|
|
|
import emu.grasscutter.game.player.TeamInfo;
|
2022-04-27 04:21:57 +00:00
|
|
|
import emu.grasscutter.net.packet.BasePacket;
|
2022-04-17 12:43:07 +00:00
|
|
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
|
|
|
import emu.grasscutter.net.proto.AvatarDataNotifyOuterClass.AvatarDataNotify;
|
|
|
|
import emu.grasscutter.net.proto.AvatarTeamOuterClass.AvatarTeam;
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
public class PacketAvatarDataNotify extends BasePacket {
|
2022-04-17 12:43:07 +00:00
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
public PacketAvatarDataNotify(Player player) {
|
2022-04-17 12:43:07 +00:00
|
|
|
super(PacketOpcodes.AvatarDataNotify, 2);
|
|
|
|
|
|
|
|
AvatarDataNotify.Builder proto = AvatarDataNotify.newBuilder()
|
|
|
|
.setCurAvatarTeamId(player.getTeamManager().getCurrentTeamId())
|
|
|
|
.setChooseAvatarGuid(player.getTeamManager().getCurrentCharacterGuid())
|
|
|
|
.addAllOwnedFlycloakList(player.getFlyCloakList())
|
|
|
|
.addAllOwnedCostumeList(player.getCostumeList());
|
|
|
|
|
2022-04-27 04:21:57 +00:00
|
|
|
for (Avatar avatar : player.getAvatars()) {
|
2022-04-17 12:43:07 +00:00
|
|
|
proto.addAvatarList(avatar.toProto());
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Entry<Integer, TeamInfo> entry : player.getTeamManager().getTeams().entrySet()) {
|
|
|
|
TeamInfo teamInfo = entry.getValue();
|
|
|
|
AvatarTeam.Builder avatarTeam = AvatarTeam.newBuilder()
|
|
|
|
.setTeamName(teamInfo.getName());
|
|
|
|
|
|
|
|
for (int i = 0; i < teamInfo.getAvatars().size(); i++) {
|
2022-04-27 04:21:57 +00:00
|
|
|
Avatar avatar = player.getAvatars().getAvatarById(teamInfo.getAvatars().get(i));
|
2022-04-17 12:43:07 +00:00
|
|
|
avatarTeam.addAvatarGuidList(avatar.getGuid());
|
|
|
|
}
|
|
|
|
|
|
|
|
proto.putAvatarTeamMap(entry.getKey(), avatarTeam.build());
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setData(proto.build());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|