mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 04:03:22 +08:00
Added interface display for multiplayer games (#360)
This commit is contained in:
parent
79165aa402
commit
7e6b20de1a
@ -83,6 +83,9 @@ public class GiveAllCommand implements CommandHandler {
|
||||
Avatar avatar = new Avatar(avatarData);
|
||||
avatar.setLevel(90);
|
||||
avatar.setPromoteLevel(6);
|
||||
for(int i = 1;i <= 6;++i){
|
||||
avatar.getTalentIdList().add((avatar.getAvatarId()-10000000)*10+i);
|
||||
}
|
||||
// This will handle stats and talents
|
||||
avatar.recalcStats();
|
||||
player.addAvatar(avatar);
|
||||
|
@ -0,0 +1,15 @@
|
||||
package emu.grasscutter.server.packet.recv;
|
||||
|
||||
import emu.grasscutter.net.packet.Opcodes;
|
||||
import emu.grasscutter.net.packet.PacketHandler;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.server.game.GameSession;
|
||||
import emu.grasscutter.server.packet.send.PacketGetOnlinePlayerListRsp;
|
||||
|
||||
@Opcodes(PacketOpcodes.GetOnlinePlayerListReq)
|
||||
public class HandlerGetOnlinePlayerListReq extends PacketHandler {
|
||||
@Override
|
||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||
session.send(new PacketGetOnlinePlayerListRsp(session.getPlayer()));
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package emu.grasscutter.server.packet.send;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.net.packet.BasePacket;
|
||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||
import emu.grasscutter.net.proto.GetOnlinePlayerListReqOuterClass;
|
||||
import emu.grasscutter.net.proto.GetOnlinePlayerListRspOuterClass.*;
|
||||
import emu.grasscutter.net.proto.MpSettingTypeOuterClass;
|
||||
import emu.grasscutter.net.proto.OnlinePlayerInfoOuterClass.OnlinePlayerInfo;
|
||||
import emu.grasscutter.net.proto.ProfilePictureOuterClass.ProfilePicture;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PacketGetOnlinePlayerListRsp extends BasePacket {
|
||||
public PacketGetOnlinePlayerListRsp(Player session){
|
||||
super(PacketOpcodes.GetOnlinePlayerListRsp);
|
||||
Map<Integer, Player> playersMap = Grasscutter.getGameServer().getPlayers();
|
||||
GetOnlinePlayerListRsp.Builder proto = GetOnlinePlayerListRsp.newBuilder();
|
||||
if(playersMap.size() != 0){
|
||||
List<OnlinePlayerInfo> playerInfoList = new ArrayList<>();
|
||||
|
||||
for(Player player:playersMap.values()){
|
||||
ProfilePicture.Builder picture = ProfilePicture.newBuilder();
|
||||
OnlinePlayerInfo.Builder playerInfo = OnlinePlayerInfo.newBuilder();
|
||||
|
||||
if(player.getUid() == session.getUid())continue;
|
||||
picture.setAvatarId(player.getProfile().getAvatarId())
|
||||
.build();
|
||||
System.out.println(player.getHeadImage());
|
||||
playerInfo.setUid(player.getUid())
|
||||
.setNickname(player.getNickname())
|
||||
.setPlayerLevel(player.getLevel())
|
||||
.setMpSettingType(MpSettingTypeOuterClass.MpSettingType.MP_SETTING_ENTER_AFTER_APPLY)
|
||||
.setCurPlayerNumInWorld(player.getWorld().getPlayerCount())
|
||||
.setWorldLevel(player.getWorldLevel())
|
||||
.setNameCardId(player.getNameCardId())
|
||||
.setProfilePicture(picture);
|
||||
if(!Objects.equals(player.getSignature(), "")){
|
||||
playerInfo.setSignature(player.getSignature());
|
||||
}
|
||||
playerInfoList.add(playerInfo.build());
|
||||
}
|
||||
for (OnlinePlayerInfo onlinePlayerInfo : playerInfoList) {
|
||||
proto.addPlayerInfoList(onlinePlayerInfo).build();
|
||||
}
|
||||
}
|
||||
this.setData(proto);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user