Skip to content

Commit

Permalink
fix: force sort scheduled events
Browse files Browse the repository at this point in the history
  • Loading branch information
MrExplode committed Nov 6, 2024
1 parent f4c4110 commit 9697f8a
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ public class SchedulerModule extends ToggleableModule {
public SchedulerModule(EventBus bus) {
super(bus);
init();
scheduledEvents.sort(Comparator.comparing(ScheduledEvent::getExecuteTime));
}

public void addEvent(ScheduledEvent event) {
scheduledEvents.add(event);
new EventAddEvent(event).call(eventBus);
//only sort if the last event's time is bigger than the added event
if (!scheduledEvents.isEmpty() && event.getExecuteTime().compareTo(scheduledEvents.getLast().getExecuteTime()) < 0)
// if (!scheduledEvents.isEmpty() && event.getExecuteTime().compareTo(scheduledEvents.getLast().getExecuteTime()) < 0)
scheduledEvents.sort(Comparator.comparing(ScheduledEvent::getExecuteTime));
}

Expand Down

0 comments on commit 9697f8a

Please sign in to comment.