Skip to content

Commit

Permalink
Add support for adding multiple display avatars for the server consol…
Browse files Browse the repository at this point in the history
…e friend
  • Loading branch information
Melledy committed Jun 20, 2024
1 parent 9e90c52 commit 82fad62
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/main/java/emu/lunarcore/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<ServerDisplayAvatar> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 82fad62

Please sign in to comment.