Add daily and weekly mission reset.

This commit is contained in:
GanyusLeftHorn
2022-06-27 00:54:17 -07:00
committed by Melledy
parent 814d4819d4
commit 8104378b95
3 changed files with 59 additions and 4 deletions

View File

@@ -77,6 +77,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import lombok.Getter;
import java.time.DayOfWeek;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
@@ -1368,7 +1369,7 @@ public class Player {
this.getResinManager().rechargeResin();
}
private void doDailyReset() {
private synchronized void doDailyReset() {
// Check if we should execute a daily reset on this tick.
int currentTime = Utils.getCurrentSeconds();
@@ -1383,6 +1384,14 @@ public class Player {
// Reset forge points.
this.setForgePoints(300_000);
// Reset daily BP missions.
this.getBattlePassManager().resetDailyMissions();
// Reset weekly BP missions.
if (currentDate.getDayOfWeek() == DayOfWeek.MONDAY) {
this.getBattlePassManager().resetWeeklyMissions();
}
// Done. Update last reset time.
this.setLastDailyReset(currentTime);
}
@@ -1455,6 +1464,9 @@ public class Player {
this.setProperty(PlayerProperty.PROP_PLAYER_MP_SETTING_TYPE, this.getMpSetting().getNumber(), false);
this.setProperty(PlayerProperty.PROP_IS_MP_MODE_AVAILABLE, 1, false);
// Execute daily reset logic if this is a new day.
this.doDailyReset();
// Packets
session.send(new PacketPlayerDataNotify(this)); // Player data
session.send(new PacketStoreWeightLimitNotify());