From 82fad62eaab96582dd0d8e83560903b999e0254b Mon Sep 17 00:00:00 2001 From: Melledy <121644117+Melledy@users.noreply.github.com> Date: Wed, 19 Jun 2024 21:32:02 -0700 Subject: [PATCH] Add support for adding multiple display avatars for the server console friend --- src/main/java/emu/lunarcore/Config.java | 14 ++++++++++++-- .../send/PacketGetFriendListInfoScRsp.java | 17 ++++++++++++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/main/java/emu/lunarcore/Config.java b/src/main/java/emu/lunarcore/Config.java index 3563b9e3c..75cbdb799 100644 --- a/src/main/java/emu/lunarcore/Config.java +++ b/src/main/java/emu/lunarcore/Config.java @@ -160,8 +160,18 @@ public static class ServerProfile { public int level = 1; public int headIcon = 201001; public int chatBubbleId = 0; - public int displayAvatarId = 1001; - public int displayAvatarLevel = 1; + public List displayAvatars = List.of(new ServerDisplayAvatar(1001, 1)); + + @Getter + public static class ServerDisplayAvatar { + public int avatarId; + public int level; + + public ServerDisplayAvatar(int avatarId, int level) { + this.avatarId = avatarId; + this.level = level; + } + } } @Getter diff --git a/src/main/java/emu/lunarcore/server/packet/send/PacketGetFriendListInfoScRsp.java b/src/main/java/emu/lunarcore/server/packet/send/PacketGetFriendListInfoScRsp.java index 15ed7eed2..602ce72ad 100644 --- a/src/main/java/emu/lunarcore/server/packet/send/PacketGetFriendListInfoScRsp.java +++ b/src/main/java/emu/lunarcore/server/packet/send/PacketGetFriendListInfoScRsp.java @@ -30,12 +30,27 @@ public PacketGetFriendListInfoScRsp(FriendList friendList) { .setChatBubbleId(serverFriendInfo.getChatBubbleId()) .setOnlineStatus(FriendOnlineStatus.FRIEND_ONLINE_STATUS_ONLINE) .setPlatformType(PlatformType.PC) - .addAssistSimpleInfo(AssistSimpleInfo.newInstance().setAvatarId(serverFriendInfo.getDisplayAvatarId()).setLevel(serverFriendInfo.getDisplayAvatarLevel())) .setHeadIcon(serverFriendInfo.getHeadIcon()); + + // Add server display avatars + if (serverFriendInfo.getDisplayAvatars() != null) { + for (int pos = 0; pos < serverFriendInfo.getDisplayAvatars().size(); pos++) { + var displayAvatar = serverFriendInfo.getDisplayAvatars().get(pos); + + var info = AssistSimpleInfo.newInstance() + .setAvatarId(displayAvatar.getAvatarId()) + .setLevel(displayAvatar.getLevel()) + .setPos(pos); + + consoleFriend.addAssistSimpleInfo(info); + } + } + // Create proto and add the server console info to it var data = GetFriendListInfoScRsp.newInstance() .addFriendList(FriendListInfo.newInstance().setSimpleInfo(consoleFriend)); + // Add friend infos for (var friendship : friendList.getFriends().values()) { var friend = friendList.getServer().getPlayerByUid(friendship.getFriendUid(), true); if (friend == null) continue;