mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-26 18:22:54 +08:00
Move persistant logger calls to trace
This commit is contained in:
parent
71a8ca2a8a
commit
97f74d9d55
@ -360,7 +360,10 @@ public class QuestManager extends BasePlayerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void triggerEvent(QuestContent condType, String paramStr, int... params) {
|
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<GameMainQuest> checkMainQuests = this.getMainQuests().values().stream()
|
List<GameMainQuest> checkMainQuests = this.getMainQuests().values().stream()
|
||||||
.filter(i -> i.getState() != ParentQuestState.PARENT_QUEST_STATE_FINISHED)
|
.filter(i -> i.getState() != ParentQuestState.PARENT_QUEST_STATE_FINISHED)
|
||||||
.toList();
|
.toList();
|
||||||
|
@ -1,65 +1,64 @@
|
|||||||
package emu.grasscutter.task.tasks;
|
package emu.grasscutter.task.tasks;
|
||||||
|
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.game.systems.AnnouncementSystem;
|
import emu.grasscutter.game.systems.AnnouncementSystem;
|
||||||
import emu.grasscutter.task.Task;
|
import emu.grasscutter.task.Task;
|
||||||
import emu.grasscutter.task.TaskHandler;
|
import emu.grasscutter.task.TaskHandler;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.quartz.JobExecutionContext;
|
import org.quartz.JobExecutionContext;
|
||||||
import org.quartz.JobExecutionException;
|
import org.quartz.JobExecutionException;
|
||||||
|
|
||||||
@Task(
|
@Task(
|
||||||
taskName = "Announcement",
|
taskName = "Announcement",
|
||||||
taskCronExpression = "0 * * * * ?",
|
taskCronExpression = "0 * * * * ?",
|
||||||
triggerName = "AnnouncementTrigger")
|
triggerName = "AnnouncementTrigger")
|
||||||
public final class AnnouncementTask extends TaskHandler {
|
public final class AnnouncementTask extends TaskHandler {
|
||||||
|
|
||||||
static Map<Integer, Integer> intervalMap = new ConcurrentHashMap<>();
|
static Map<Integer, Integer> intervalMap = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
Grasscutter.getLogger().debug("[Task] Announcement task enabled.");
|
Grasscutter.getLogger().debug("[Task] Announcement task enabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
Grasscutter.getLogger().debug("[Task] Announcement task disabled.");
|
Grasscutter.getLogger().debug("[Task] Announcement task disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void execute(JobExecutionContext context) throws JobExecutionException {
|
public synchronized void execute(JobExecutionContext context) throws JobExecutionException {
|
||||||
var current = new Date();
|
var current = new Date();
|
||||||
var announceConfigItems =
|
var announceConfigItems =
|
||||||
Grasscutter.getGameServer()
|
Grasscutter.getGameServer()
|
||||||
.getAnnouncementSystem()
|
.getAnnouncementSystem()
|
||||||
.getAnnounceConfigItemMap()
|
.getAnnounceConfigItemMap()
|
||||||
.values()
|
.values()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(AnnouncementSystem.AnnounceConfigItem::isTick)
|
.filter(AnnouncementSystem.AnnounceConfigItem::isTick)
|
||||||
.filter(i -> current.after(i.getBeginTime()))
|
.filter(i -> current.after(i.getBeginTime()))
|
||||||
.filter(i -> current.before(i.getEndTime()))
|
.filter(i -> current.before(i.getEndTime()))
|
||||||
.collect(
|
.collect(
|
||||||
Collectors.toMap(AnnouncementSystem.AnnounceConfigItem::getTemplateId, y -> y));
|
Collectors.toMap(AnnouncementSystem.AnnounceConfigItem::getTemplateId, y -> y));
|
||||||
|
|
||||||
announceConfigItems
|
announceConfigItems
|
||||||
.values()
|
.values()
|
||||||
.forEach(i -> intervalMap.compute(i.getTemplateId(), (k, v) -> v == null ? 1 : v + 1));
|
.forEach(i -> intervalMap.compute(i.getTemplateId(), (k, v) -> v == null ? 1 : v + 1));
|
||||||
|
|
||||||
var toSend =
|
var toSend =
|
||||||
intervalMap.entrySet().stream()
|
intervalMap.entrySet().stream()
|
||||||
.filter(i -> announceConfigItems.containsKey(i.getKey()))
|
.filter(i -> announceConfigItems.containsKey(i.getKey()))
|
||||||
.filter(i -> i.getValue() >= announceConfigItems.get(i.getKey()).getInterval())
|
.filter(i -> i.getValue() >= announceConfigItems.get(i.getKey()).getInterval())
|
||||||
.map(i -> announceConfigItems.get(i.getKey()))
|
.map(i -> announceConfigItems.get(i.getKey()))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
Grasscutter.getGameServer().getAnnouncementSystem().broadcast(toSend);
|
Grasscutter.getGameServer().getAnnouncementSystem().broadcast(toSend);
|
||||||
Grasscutter.getLogger()
|
Grasscutter.getLogger().trace("Broadcast {} announcement(s) to all online players", toSend.size());
|
||||||
.debug("Broadcast {} announcement(s) to all online players", toSend.size());
|
|
||||||
|
// clear the interval count
|
||||||
// clear the interval count
|
toSend.forEach(i -> intervalMap.put(i.getTemplateId(), 0));
|
||||||
toSend.forEach(i -> intervalMap.put(i.getTemplateId(), 0));
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user