Skip to content

Commit

Permalink
fix: allow offline player
Browse files Browse the repository at this point in the history
  • Loading branch information
hamusuke0323 committed Aug 30, 2023
1 parent 8d5bacd commit a12b10d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/main/java/emu/grasscutter/game/friends/Friendship.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void delete() {
}

public FriendBrief toProto() {
this.getFriendProfile().getPlayer(); // check if player is online and sync player if online.
var player = this.getFriendProfile().getPlayer(); // get latest player and sync.

return FriendBrief.newBuilder()
.setUid(getFriendProfile().getUid())
Expand All @@ -106,7 +106,7 @@ public FriendBrief toProto() {
.setWorldLevel(getFriendProfile().getWorldLevel())
.setSignature(getFriendProfile().getSignature())
.setOnlineState(
getFriendProfile().isOnline()
player != null && player.isOnline()
? FriendOnlineState.FRIEND_ONLINE_STATE_ONLINE
: FriendOnlineState.FRIEND_ONLINE_STATE_DISCONNECT)
.setIsMpModeAvailable(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public PlayerProfile(Player player) {

@Nullable
public Player getPlayer() {
var player = Grasscutter.getGameServer().getPlayerByUid(this.getUid());
var player = Grasscutter.getGameServer().getPlayerByUid(this.getUid(), true);
this.syncWithCharacter(player);
return player;
}
Expand All @@ -49,10 +49,6 @@ public int getDaysSinceLogin() {
return (int) Math.floor((Utils.getCurrentSeconds() - getLastActiveTime()) / 86400.0);
}

public boolean isOnline() {
return this.getPlayer() != null;
}

public void syncWithCharacter(Player player) {
if (player == null) {
return;
Expand Down

0 comments on commit a12b10d

Please sign in to comment.