From d74a7c02284ac1d05f1917a7a3a8309a637197c5 Mon Sep 17 00:00:00 2001 From: Nazrin Date: Sat, 30 Mar 2024 04:14:48 -0700 Subject: [PATCH] Have timers trigger by events with source = "". Remove redundant checking code. --- .../scripts/SceneScriptManager.java | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java index 029041ae..297b07b6 100644 --- a/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java +++ b/src/main/java/emu/grasscutter/scripts/SceneScriptManager.java @@ -993,19 +993,12 @@ public class SceneScriptManager { } logger.info("creating group timer event for group {} with source {} and time {}", groupID, source, time); - for(SceneTrigger trigger : group.getTriggers().values()){ - if(trigger.getEvent() == EVENT_TIMER_EVENT &&trigger.getSource().equals(source)){ - logger.warn("[LUA] Found timer trigger with source {} for group {} : {}", - source, groupID, trigger.getName()); - cancelGroupTimerEvent(groupID, source); - var taskIdentifier = Grasscutter.getGameServer().getScheduler().scheduleDelayedRepeatingTask(() -> - callEvent(new ScriptArgs(groupID, EVENT_TIMER_EVENT) - .setEventSource(source)), (int)time, (int)time); - var groupTasks = activeGroupTimers.computeIfAbsent(groupID, k -> new HashSet<>()); - groupTasks.add(new Pair<>(source, taskIdentifier)); - - } - } + cancelGroupTimerEvent(groupID, source); + var taskIdentifier = Grasscutter.getGameServer().getScheduler().scheduleDelayedRepeatingTask(() -> + callEvent(new ScriptArgs(groupID, EVENT_TIMER_EVENT) + .setEventSource(source)), (int)time, (int)time); + var groupTasks = activeGroupTimers.computeIfAbsent(groupID, k -> new HashSet<>()); + groupTasks.add(new Pair<>(source, taskIdentifier)); return 0; } public int cancelGroupTimerEvent(int groupID, String source) {