MoonCard.java 1008 Bytes
Newer Older
Yazawazi's avatar
Yazawazi committed
1
2
3
4
5
6
7
8
9
10
11
12
13
package emu.grasscutter.task.tasks;

import emu.grasscutter.database.DatabaseManager;
import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.task.Task;
import emu.grasscutter.task.TaskHandler;

import java.util.List;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

@Task(taskName = "MoonCard", taskCronExpression = "0 0 0 * * ?", triggerName = "MoonCardTrigger")
Yazawazi's avatar
Yazawazi committed
14
// taskCronExpression: Fixed time period: 0:0:0 every day (twenty-four hour system)
Yazawazi's avatar
Yazawazi committed
15
16
17
18
19
20
21
22
23
24
25
26
27
public final class MoonCard implements TaskHandler {
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        List<GenshinPlayer> players = DatabaseManager.getDatastore().find(GenshinPlayer.class).stream().toList();
        for (GenshinPlayer player : players) {
            if (player.isOnline()) {
                if (player.inMoonCard()) {
                    player.getTodayMoonCard();
                }
            }
        }
    }
}