diff --git a/src/main/java/emu/grasscutter/game/quest/QuestManager.java b/src/main/java/emu/grasscutter/game/quest/QuestManager.java index 021c46fe1..a9a4c8b2f 100644 --- a/src/main/java/emu/grasscutter/game/quest/QuestManager.java +++ b/src/main/java/emu/grasscutter/game/quest/QuestManager.java @@ -360,7 +360,10 @@ public class QuestManager extends BasePlayerManager { } public void triggerEvent(QuestContent condType, String paramStr, int... params) { - Grasscutter.getLogger().debug("Trigger Event {}, {}, {}", condType, paramStr, params); + if (condType != QuestContent.QUEST_CONTENT_GAME_TIME_TICK) + Grasscutter.getLogger().debug("Trigger Event {}, {}, {}", condType, paramStr, params); + else Grasscutter.getLogger().trace("Trigger Event {}, {}, {}", condType, paramStr, params); + List checkMainQuests = this.getMainQuests().values().stream() .filter(i -> i.getState() != ParentQuestState.PARENT_QUEST_STATE_FINISHED) .toList(); diff --git a/src/main/java/emu/grasscutter/task/tasks/AnnouncementTask.java b/src/main/java/emu/grasscutter/task/tasks/AnnouncementTask.java index da0b8bf9c..25e23cb05 100644 --- a/src/main/java/emu/grasscutter/task/tasks/AnnouncementTask.java +++ b/src/main/java/emu/grasscutter/task/tasks/AnnouncementTask.java @@ -1,65 +1,64 @@ -package emu.grasscutter.task.tasks; - -import emu.grasscutter.Grasscutter; -import emu.grasscutter.game.systems.AnnouncementSystem; -import emu.grasscutter.task.Task; -import emu.grasscutter.task.TaskHandler; -import java.util.Date; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.stream.Collectors; -import org.quartz.JobExecutionContext; -import org.quartz.JobExecutionException; - -@Task( - taskName = "Announcement", - taskCronExpression = "0 * * * * ?", - triggerName = "AnnouncementTrigger") -public final class AnnouncementTask extends TaskHandler { - - static Map intervalMap = new ConcurrentHashMap<>(); - - @Override - public void onEnable() { - Grasscutter.getLogger().debug("[Task] Announcement task enabled."); - } - - @Override - public void onDisable() { - Grasscutter.getLogger().debug("[Task] Announcement task disabled."); - } - - @Override - public synchronized void execute(JobExecutionContext context) throws JobExecutionException { - var current = new Date(); - var announceConfigItems = - Grasscutter.getGameServer() - .getAnnouncementSystem() - .getAnnounceConfigItemMap() - .values() - .stream() - .filter(AnnouncementSystem.AnnounceConfigItem::isTick) - .filter(i -> current.after(i.getBeginTime())) - .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)); - - var toSend = - intervalMap.entrySet().stream() - .filter(i -> announceConfigItems.containsKey(i.getKey())) - .filter(i -> i.getValue() >= announceConfigItems.get(i.getKey()).getInterval()) - .map(i -> announceConfigItems.get(i.getKey())) - .toList(); - - Grasscutter.getGameServer().getAnnouncementSystem().broadcast(toSend); - Grasscutter.getLogger() - .debug("Broadcast {} announcement(s) to all online players", toSend.size()); - - // clear the interval count - toSend.forEach(i -> intervalMap.put(i.getTemplateId(), 0)); - } -} +package emu.grasscutter.task.tasks; + +import emu.grasscutter.Grasscutter; +import emu.grasscutter.game.systems.AnnouncementSystem; +import emu.grasscutter.task.Task; +import emu.grasscutter.task.TaskHandler; +import java.util.Date; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +@Task( + taskName = "Announcement", + taskCronExpression = "0 * * * * ?", + triggerName = "AnnouncementTrigger") +public final class AnnouncementTask extends TaskHandler { + + static Map intervalMap = new ConcurrentHashMap<>(); + + @Override + public void onEnable() { + Grasscutter.getLogger().debug("[Task] Announcement task enabled."); + } + + @Override + public void onDisable() { + Grasscutter.getLogger().debug("[Task] Announcement task disabled."); + } + + @Override + public synchronized void execute(JobExecutionContext context) throws JobExecutionException { + var current = new Date(); + var announceConfigItems = + Grasscutter.getGameServer() + .getAnnouncementSystem() + .getAnnounceConfigItemMap() + .values() + .stream() + .filter(AnnouncementSystem.AnnounceConfigItem::isTick) + .filter(i -> current.after(i.getBeginTime())) + .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)); + + var toSend = + intervalMap.entrySet().stream() + .filter(i -> announceConfigItems.containsKey(i.getKey())) + .filter(i -> i.getValue() >= announceConfigItems.get(i.getKey()).getInterval()) + .map(i -> announceConfigItems.get(i.getKey())) + .toList(); + + Grasscutter.getGameServer().getAnnouncementSystem().broadcast(toSend); + Grasscutter.getLogger().trace("Broadcast {} announcement(s) to all online players", toSend.size()); + + // clear the interval count + toSend.forEach(i -> intervalMap.put(i.getTemplateId(), 0)); + } +}