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
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
11
// taskCronExpression: Fixed time period: 0:0:0 every day (twenty-four hour system)
KingRainbow44's avatar
KingRainbow44 committed
12
public final class MoonCard extends TaskHandler {
Yazawazi's avatar
Yazawazi committed
13
14
15

    @Override
    public void onEnable() {
KingRainbow44's avatar
KingRainbow44 committed
16
        Grasscutter.getLogger().debug("[Task] MoonCard task enabled.");
Yazawazi's avatar
Yazawazi committed
17
18
19
20
    }

    @Override
    public void onDisable() {
KingRainbow44's avatar
KingRainbow44 committed
21
        Grasscutter.getLogger().debug("[Task] MoonCard task disabled.");
Yazawazi's avatar
Yazawazi committed
22
23
    }

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