Update mail state on login

This commit is contained in:
Melledy
2025-11-07 07:05:09 -08:00
parent 86b2933aa1
commit e10dd6310b
2 changed files with 12 additions and 2 deletions

View File

@@ -55,6 +55,14 @@ public class Mailbox extends PlayerManager implements GameDatabaseObject, Iterab
.orElse(null); .orElse(null);
} }
public boolean hasNewMail() {
return this.getList()
.stream()
.filter(mail -> !mail.isRead() && !mail.isRecv())
.findAny()
.isPresent();
}
public void sendMail(GameMail mail) { public void sendMail(GameMail mail) {
// Set mail id // Set mail id
mail.setId(++this.lastMailId); mail.setId(++this.lastMailId);

View File

@@ -526,11 +526,13 @@ public class Player implements GameDatabaseObject {
proto.getMutableFormation().addInfo(f.toProto()); proto.getMutableFormation().addInfo(f.toProto());
} }
// Set state // Set player states
var state = proto.getMutableState() var state = proto.getMutableState()
.setStorySet(true); .setStorySet(true);
state.getMutableMail(); state.getMutableMail()
.setNew(this.getMailbox().hasNewMail());
state.getMutableBattlePass(); state.getMutableBattlePass();
state.getMutableFriendEnergy(); state.getMutableFriendEnergy();
state.getMutableMallPackage(); state.getMutableMallPackage();