MoonCard.java 1.08 KB
Newer Older
Yazawazi's avatar
Yazawazi committed
1
2
package emu.grasscutter.task.tasks;

Yazawazi's avatar
Yazawazi committed
3
import emu.grasscutter.Grasscutter;
Yazawazi's avatar
Yazawazi committed
4
5
6
7
8
9
10
11
import emu.grasscutter.task.Task;
import emu.grasscutter.task.TaskHandler;


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

@Task(taskName = "MoonCard", taskCronExpression = "0 0 0 * * ?", triggerName = "MoonCardTrigger")
Yazawazi's avatar
Yazawazi committed
12
// taskCronExpression: Fixed time period: 0:0:0 every day (twenty-four hour system)
Yazawazi's avatar
Yazawazi committed
13
public class MoonCard extends TaskHandler {
Yazawazi's avatar
Yazawazi committed
14
15
16
17
18
19
20
21
22
23
24

    @Override
    public void onEnable() {
        Grasscutter.getLogger().info("[Task] MoonCard task enabled.");
    }

    @Override
    public void onDisable() {
        Grasscutter.getLogger().info("[Task] MoonCard task disabled.");
    }

Yazawazi's avatar
Yazawazi committed
25
    @Override
Yazawazi's avatar
Yazawazi committed
26
27
    public synchronized void execute(JobExecutionContext context) throws JobExecutionException {
        Grasscutter.getGameServer().getPlayers().forEach((uid, player) -> {
Yazawazi's avatar
Yazawazi committed
28
29
30
31
32
            if (player.isOnline()) {
                if (player.inMoonCard()) {
                    player.getTodayMoonCard();
                }
            }
Yazawazi's avatar
Yazawazi committed
33
        });
Yazawazi's avatar
Yazawazi committed
34
35
    }
}