MoonCard.java 987 Bytes
Newer Older
Yazawazi's avatar
Yazawazi committed
1
2
3
package emu.grasscutter.task.tasks;

import emu.grasscutter.database.DatabaseManager;
Melledy's avatar
Melledy committed
4
import emu.grasscutter.game.player.Player;
Yazawazi's avatar
Yazawazi committed
5
6
7
8
9
10
11
12
13
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
public final class MoonCard implements TaskHandler {
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
18
19
        List<Player> players = DatabaseManager.getDatastore().find(Player.class).stream().toList();
        for (Player player : players) {
Yazawazi's avatar
Yazawazi committed
20
21
22
23
24
25
26
27
            if (player.isOnline()) {
                if (player.inMoonCard()) {
                    player.getTodayMoonCard();
                }
            }
        }
    }
}