mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-20 19:04:40 +01:00
Run IntelliJ IDEA code formatter
This commit is contained in:
@@ -1,32 +1,36 @@
|
||||
package emu.grasscutter.task;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
|
||||
/*
|
||||
* So what is cron expression?
|
||||
The format of a Cron expression is as follows.
|
||||
Second Minute Hour Day Month Week Year
|
||||
Seconds: 0-59
|
||||
Minute: 0-59
|
||||
hour: 0-23
|
||||
Day: 1-31
|
||||
Month: 1-12
|
||||
Week: 1-7 (0-6 sometimes)
|
||||
Year: Specify your own
|
||||
|
||||
If you want to express every second or every minute or something like that, use the * symbol in that position;
|
||||
if you want to express more than one such as every 15 minutes and every 30 minutes, you can write:`15, 30`.
|
||||
|
||||
For the rest of the wildcard characters, please Google them yourself
|
||||
*/
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Task {
|
||||
String taskName() default "NO_NAME";
|
||||
String taskCronExpression() default "0 0 0 0 0 ?";
|
||||
String triggerName() default "NO_NAME";
|
||||
boolean executeImmediatelyAfterReset() default false;
|
||||
boolean executeImmediately() default false;
|
||||
}
|
||||
package emu.grasscutter.task;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
|
||||
/*
|
||||
* So what is cron expression?
|
||||
The format of a Cron expression is as follows.
|
||||
Second Minute Hour Day Month Week Year
|
||||
Seconds: 0-59
|
||||
Minute: 0-59
|
||||
hour: 0-23
|
||||
Day: 1-31
|
||||
Month: 1-12
|
||||
Week: 1-7 (0-6 sometimes)
|
||||
Year: Specify your own
|
||||
|
||||
If you want to express every second or every minute or something like that, use the * symbol in that position;
|
||||
if you want to express more than one such as every 15 minutes and every 30 minutes, you can write:`15, 30`.
|
||||
|
||||
For the rest of the wildcard characters, please Google them yourself
|
||||
*/
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Task {
|
||||
String taskName() default "NO_NAME";
|
||||
|
||||
String taskCronExpression() default "0 0 0 0 0 ?";
|
||||
|
||||
String triggerName() default "NO_NAME";
|
||||
|
||||
boolean executeImmediatelyAfterReset() default false;
|
||||
|
||||
boolean executeImmediately() default false;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
package emu.grasscutter.task;
|
||||
|
||||
import org.quartz.*;
|
||||
|
||||
@PersistJobDataAfterExecution
|
||||
public abstract class TaskHandler implements Job {
|
||||
public void restartExecute() throws JobExecutionException {
|
||||
execute(null);
|
||||
}
|
||||
|
||||
public abstract void onEnable();
|
||||
|
||||
public abstract void onDisable();
|
||||
}
|
||||
package emu.grasscutter.task;
|
||||
|
||||
import org.quartz.Job;
|
||||
import org.quartz.JobExecutionException;
|
||||
import org.quartz.PersistJobDataAfterExecution;
|
||||
|
||||
@PersistJobDataAfterExecution
|
||||
public abstract class TaskHandler implements Job {
|
||||
public void restartExecute() throws JobExecutionException {
|
||||
execute(null);
|
||||
}
|
||||
|
||||
public abstract void onEnable();
|
||||
|
||||
public abstract void onDisable();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package emu.grasscutter.task;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
|
||||
import org.quartz.*;
|
||||
import org.quartz.impl.StdSchedulerFactory;
|
||||
import org.reflections.Reflections;
|
||||
@@ -110,14 +109,14 @@ public final class TaskMap {
|
||||
try {
|
||||
Scheduler scheduler = schedulerFactory.getScheduler();
|
||||
JobDetail job = JobBuilder
|
||||
.newJob(task.getClass())
|
||||
.withIdentity(taskName)
|
||||
.build();
|
||||
.newJob(task.getClass())
|
||||
.withIdentity(taskName)
|
||||
.build();
|
||||
|
||||
Trigger convTrigger = TriggerBuilder.newTrigger()
|
||||
.withIdentity(annotation.triggerName())
|
||||
.withSchedule(CronScheduleBuilder.cronSchedule(annotation.taskCronExpression()))
|
||||
.build();
|
||||
.withIdentity(annotation.triggerName())
|
||||
.withSchedule(CronScheduleBuilder.cronSchedule(annotation.taskCronExpression()))
|
||||
.build();
|
||||
|
||||
scheduler.scheduleJob(job, convTrigger);
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import java.util.stream.Collectors;
|
||||
public final class AnnouncementTask extends TaskHandler {
|
||||
|
||||
static Map<Integer, Integer> intervalMap = new ConcurrentHashMap<>();
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
Grasscutter.getLogger().debug("[Task] Announcement task enabled.");
|
||||
@@ -35,7 +36,7 @@ public final class AnnouncementTask extends TaskHandler {
|
||||
.filter(i -> current.before(i.getEndTime()))
|
||||
.collect(Collectors.toMap(AnnouncementSystem.AnnounceConfigItem::getTemplateId, y -> y));
|
||||
|
||||
announceConfigItems.values().forEach(i -> intervalMap.compute(i.getTemplateId(), (k,v) -> v == null ? 1 : v + 1));
|
||||
announceConfigItems.values().forEach(i -> intervalMap.compute(i.getTemplateId(), (k, v) -> v == null ? 1 : v + 1));
|
||||
|
||||
var toSend = intervalMap.entrySet().stream()
|
||||
.filter(i -> announceConfigItems.containsKey(i.getKey()))
|
||||
|
||||
@@ -1,34 +1,33 @@
|
||||
package emu.grasscutter.task.tasks;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
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")
|
||||
// taskCronExpression: Fixed time period: 0:0:0 every day (twenty-four hour system)
|
||||
public final class MoonCard extends TaskHandler {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
Grasscutter.getLogger().debug("[Task] MoonCard task enabled.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Grasscutter.getLogger().debug("[Task] MoonCard task disabled.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
Grasscutter.getGameServer().getPlayers().forEach((uid, player) -> {
|
||||
if (player.isOnline()) {
|
||||
if (player.inMoonCard()) {
|
||||
player.getTodayMoonCard();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
package emu.grasscutter.task.tasks;
|
||||
|
||||
import emu.grasscutter.Grasscutter;
|
||||
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")
|
||||
// taskCronExpression: Fixed time period: 0:0:0 every day (twenty-four hour system)
|
||||
public final class MoonCard extends TaskHandler {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
Grasscutter.getLogger().debug("[Task] MoonCard task enabled.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Grasscutter.getLogger().debug("[Task] MoonCard task disabled.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void execute(JobExecutionContext context) throws JobExecutionException {
|
||||
Grasscutter.getGameServer().getPlayers().forEach((uid, player) -> {
|
||||
if (player.isOnline()) {
|
||||
if (player.inMoonCard()) {
|
||||
player.getTodayMoonCard();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user