38 lines
1.1 KiB
Java
38 lines
1.1 KiB
Java
package net.t2code.automatedMessages.messages;
|
|
|
|
import net.t2code.automatedMessages.config.FileBuild;
|
|
import net.t2code.automatedMessages.config.messages.MessagesSelect;
|
|
import net.t2code.automatedMessages.objects.Message;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
public class Management {
|
|
private static final List<Timer> timerJobList = new ArrayList<>();
|
|
private static final List<CronJob> cronJobs = new ArrayList<>();
|
|
|
|
public static void start() {
|
|
for (Map.Entry<String, Message> value : MessagesSelect.getMessageHashMap().entrySet()) {
|
|
Message message = value.getValue();
|
|
if (!message.enable) continue;
|
|
if (message.exactTime) {
|
|
CronJob cronJob = new CronJob(message);
|
|
cronJobs.add(cronJob);
|
|
} else {
|
|
Timer job = new Timer(message);
|
|
timerJobList.add(job);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void end() {
|
|
for (Timer job : timerJobList) {
|
|
job.disable = true;
|
|
}
|
|
for (CronJob cronJob : cronJobs) {
|
|
cronJob.shutdown();
|
|
}
|
|
}
|
|
}
|