From c2a159be138be9bb5d9f7861a66628e12bed8484 Mon Sep 17 00:00:00 2001 From: Yazawazi <47273265+Yazawazi@users.noreply.github.com> Date: Thu, 28 Apr 2022 06:40:25 +0800 Subject: [PATCH] Should be OK --- .../emu/grasscutter/game/player/Player.java | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/player/Player.java b/src/main/java/emu/grasscutter/game/player/Player.java index d550e5914..75c9c21ad 100644 --- a/src/main/java/emu/grasscutter/game/player/Player.java +++ b/src/main/java/emu/grasscutter/game/player/Player.java @@ -853,15 +853,35 @@ public class Player { public SocialDetail.Builder getSocialDetail() { List socialShowAvatarInfoList = new ArrayList<>(); - for (int avatarId : this.getShowAvatarList()) { - socialShowAvatarInfoList.add( - socialShowAvatarInfoList.size(), - SocialShowAvatarInfoOuterClass.SocialShowAvatarInfo.newBuilder() - .setAvatarId(avatarId) - .setLevel(getAvatars().getAvatarById(avatarId).getLevel()) - .setCostumeId(getAvatars().getAvatarById(avatarId).getCostume()) - .build() - ); + if (this.isOnline()) { + if (this.getShowAvatarList() != null) { + for (int avatarId : this.getShowAvatarList()) { + socialShowAvatarInfoList.add( + socialShowAvatarInfoList.size(), + SocialShowAvatarInfoOuterClass.SocialShowAvatarInfo.newBuilder() + .setAvatarId(avatarId) + .setLevel(getAvatars().getAvatarById(avatarId).getLevel()) + .setCostumeId(getAvatars().getAvatarById(avatarId).getCostume()) + .build() + ); + } + } + } else { + List showAvatarList = DatabaseHelper.getPlayerById(id).getShowAvatarList(); + AvatarStorage avatars = DatabaseHelper.getPlayerById(id).getAvatars(); + avatars.loadFromDatabase(); + if (showAvatarList != null) { + for (int avatarId : showAvatarList) { + socialShowAvatarInfoList.add( + socialShowAvatarInfoList.size(), + SocialShowAvatarInfoOuterClass.SocialShowAvatarInfo.newBuilder() + .setAvatarId(avatarId) + .setLevel(avatars.getAvatarById(avatarId).getLevel()) + .setCostumeId(avatars.getAvatarById(avatarId).getCostume()) + .build() + ); + } + } } SocialDetail.Builder social = SocialDetail.newBuilder()