Have timers trigger by events with source = "". Remove redundant checking code.

This commit is contained in:
Nazrin 2024-03-30 04:14:48 -07:00 committed by GitHub
parent 7d763ba0ba
commit d74a7c0228
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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));
}
}
return 0;
}
public int cancelGroupTimerEvent(int groupID, String source) {