2022-04-17 20:43:07 +08:00
|
|
|
package emu.grasscutter.game.friends;
|
|
|
|
|
|
|
|
import dev.morphia.annotations.*;
|
2022-04-27 12:21:57 +08:00
|
|
|
import emu.grasscutter.game.Player;
|
2022-04-17 20:43:07 +08:00
|
|
|
import emu.grasscutter.utils.Utils;
|
|
|
|
|
2022-04-22 10:19:47 +08:00
|
|
|
@Entity
|
2022-04-17 20:43:07 +08:00
|
|
|
public class PlayerProfile {
|
2022-04-27 12:21:57 +08:00
|
|
|
@Transient private Player player;
|
2022-04-17 20:43:07 +08:00
|
|
|
|
2022-04-21 12:50:33 +08:00
|
|
|
@AlsoLoad("id") private int uid;
|
2022-04-17 20:43:07 +08:00
|
|
|
private int nameCard;
|
|
|
|
private int avatarId;
|
|
|
|
private String name;
|
|
|
|
private String signature;
|
|
|
|
private int achievements;
|
|
|
|
|
|
|
|
private int playerLevel;
|
|
|
|
private int worldLevel;
|
|
|
|
private int lastActiveTime;
|
|
|
|
|
|
|
|
@Deprecated // Morphia only
|
|
|
|
public PlayerProfile() { }
|
|
|
|
|
2022-04-27 12:21:57 +08:00
|
|
|
public PlayerProfile(Player player) {
|
2022-04-21 12:50:33 +08:00
|
|
|
this.uid = player.getUid();
|
2022-04-17 20:43:07 +08:00
|
|
|
this.syncWithCharacter(player);
|
|
|
|
}
|
|
|
|
|
2022-04-21 12:50:33 +08:00
|
|
|
public int getUid() {
|
|
|
|
return uid;
|
2022-04-17 20:43:07 +08:00
|
|
|
}
|
|
|
|
|
2022-04-27 12:21:57 +08:00
|
|
|
public Player getPlayer() {
|
2022-04-17 20:43:07 +08:00
|
|
|
return player;
|
|
|
|
}
|
|
|
|
|
2022-04-27 12:21:57 +08:00
|
|
|
public synchronized void setPlayer(Player player) {
|
2022-04-17 20:43:07 +08:00
|
|
|
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 getAchievements() {
|
|
|
|
return achievements;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getPlayerLevel() {
|
|
|
|
return playerLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getWorldLevel() {
|
|
|
|
return worldLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getLastActiveTime() {
|
|
|
|
return lastActiveTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void updateLastActiveTime() {
|
|
|
|
this.lastActiveTime = Utils.getCurrentSeconds();
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getDaysSinceLogin() {
|
|
|
|
return (int) Math.floor((Utils.getCurrentSeconds() - getLastActiveTime()) / 86400.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isOnline() {
|
|
|
|
return this.getPlayer() != null;
|
|
|
|
}
|
|
|
|
|
2022-04-27 12:21:57 +08:00
|
|
|
public void syncWithCharacter(Player player) {
|
2022-04-17 20:43:07 +08:00
|
|
|
if (player == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-04-21 12:50:33 +08:00
|
|
|
this.uid = player.getUid();
|
2022-04-17 20:43:07 +08:00
|
|
|
this.name = player.getNickname();
|
|
|
|
this.avatarId = player.getHeadImage();
|
|
|
|
this.signature = player.getSignature();
|
|
|
|
this.nameCard = player.getNameCardId();
|
|
|
|
this.playerLevel = player.getLevel();
|
|
|
|
this.worldLevel = player.getWorldLevel();
|
|
|
|
//this.achievements = 0;
|
|
|
|
this.updateLastActiveTime();
|
|
|
|
}
|
|
|
|
}
|