Fix battle pass red dot when logging in

This commit is contained in:
Melledy
2025-12-05 20:32:06 -08:00
parent 5182e94db7
commit 0b7f1ae3a2
3 changed files with 31 additions and 1 deletions

View File

@@ -100,6 +100,32 @@ public class BattlePass implements GameDatabaseObject {
}
}
/**
* Returns true if any rewards or quests are claimable
*/
public synchronized boolean hasNew() {
// Check if any quests are complete but unclaimed
for (var quest : getQuests().values()) {
if (quest.isComplete() && !quest.isClaimed()) {
return true;
}
}
// Check if we have any pending rewards
for (int i = 1; i <= this.getLevel(); i++) {
if (!this.getBasicReward().isSet(i)) {
return true;
}
if (this.isPremium() && !this.getPremiumReward().isSet(i)) {
return true;
}
}
// No claimable things
return false;
}
public synchronized void resetDailyQuests(boolean resetWeekly) {
// Reset daily quests
for (var data : GameData.getBattlePassQuestDataTable()) {

View File

@@ -13,6 +13,10 @@ public class BattlePassManager extends PlayerManager {
super(player);
}
public boolean hasNew() {
return this.getBattlePass().hasNew();
}
// Database
public void loadFromDatabase() {

View File

@@ -828,7 +828,7 @@ public class Player implements GameDatabaseObject {
.setNew(this.getMailbox().hasNewMail());
state.getMutableBattlePass()
.setState(1);
.setState(this.getBattlePassManager().hasNew() ? 1 : 0);
state.getMutableAchievement()
.setNew(this.getAchievementManager().hasNewAchievements());