mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-16 08:56:04 +01:00
fix: player profile changes are not reflected cuz Java is object-oriented (#2322)
* fix: player profile changes are not reflected. fix: deob FriendBrief.proto * fix: tentatively sync profile when log out * fix: allow offline player * Update src/main/java/emu/grasscutter/game/friends/PlayerProfile.java Co-authored-by: Magix <27646710+KingRainbow44@users.noreply.github.com> * Update src/main/java/emu/grasscutter/game/player/Player.java Co-authored-by: Magix <27646710+KingRainbow44@users.noreply.github.com> * Update src/main/java/emu/grasscutter/game/player/Player.java Co-authored-by: Magix <27646710+KingRainbow44@users.noreply.github.com> * fix: server friend --------- Co-authored-by: Magix <27646710+KingRainbow44@users.noreply.github.com>
This commit is contained in:
@@ -2,17 +2,21 @@ package emu.grasscutter.game.friends;
|
||||
|
||||
import dev.morphia.annotations.AlsoLoad;
|
||||
import dev.morphia.annotations.Entity;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
|
||||
import dev.morphia.annotations.Transient;
|
||||
import emu.grasscutter.game.home.GameHome;
|
||||
|
||||
import emu.grasscutter.game.player.Player;
|
||||
import emu.grasscutter.net.proto.FriendEnterHomeOptionOuterClass;
|
||||
import emu.grasscutter.utils.Utils;
|
||||
import lombok.Getter;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Entity
|
||||
@Getter
|
||||
public class PlayerProfile {
|
||||
@Transient private Player player;
|
||||
|
||||
@AlsoLoad("id")
|
||||
private int uid;
|
||||
|
||||
@@ -24,9 +28,14 @@ public class PlayerProfile {
|
||||
private int playerLevel;
|
||||
private int worldLevel;
|
||||
private int lastActiveTime;
|
||||
|
||||
private boolean isInDuel = false; // TODO: Implement duels. (TCG)
|
||||
private boolean isDuelObservable = false; // TODO: Implement duels. (TCG)
|
||||
|
||||
@Getter
|
||||
private int enterHomeOption;
|
||||
|
||||
|
||||
@Deprecated // Morphia only
|
||||
public PlayerProfile() {}
|
||||
|
||||
@@ -35,46 +44,13 @@ public class PlayerProfile {
|
||||
this.syncWithCharacter(player);
|
||||
}
|
||||
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Player getPlayer() {
|
||||
var player = Grasscutter.getGameServer().getPlayerByUid(this.getUid(), true);
|
||||
this.syncWithCharacter(player);
|
||||
return player;
|
||||
}
|
||||
|
||||
public synchronized void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getNameCard() {
|
||||
return nameCard;
|
||||
}
|
||||
|
||||
public int getAvatarId() {
|
||||
return avatarId;
|
||||
}
|
||||
|
||||
public String getSignature() {
|
||||
return signature;
|
||||
}
|
||||
|
||||
public int getPlayerLevel() {
|
||||
return playerLevel;
|
||||
}
|
||||
|
||||
public int getWorldLevel() {
|
||||
return worldLevel;
|
||||
}
|
||||
|
||||
public int getLastActiveTime() {
|
||||
return lastActiveTime;
|
||||
}
|
||||
|
||||
public void updateLastActiveTime() {
|
||||
this.lastActiveTime = Utils.getCurrentSeconds();
|
||||
}
|
||||
@@ -83,10 +59,6 @@ public class PlayerProfile {
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user