Fix EvtAtTime not triggering when world time has been changed. #6463
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The previous logic in EvtAtTime kept track of which event instance should be triggered next in a world. This works great and helps performance when the time in a world flows linearly without interruption. However, if the world time ever changes abruptly, Skript is still looking for the old "next event". So if you have 6:00 and 8:00 registered, but at 7:00 you jump back to 5:00, then the 6:00 won't trigger again, because Skript's looking for that 8:00 that "should" be next.
This change instead forces Skript to check all events against the current time (minus the ones that are ahead of the current world time). This is slightly worse for performance (very marginal) but ensures safety against time skips.
It also uses a PriorityQueue instead of re-sorting the whole list when adding events, fixes a bug where the repeating task wasn't actually cancelled on unload, and cleans up the code a bit.
Target Minecraft Versions: any
Requirements: none
Related Issues: #6462