Make event priority parsing more flexible #4502
Merged
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
I noticed that in skript-reflect Bukkit event listeners with priority weren't working properly due to the change in #3852.
Therefore, this change makes it so Skript attempts to parse the whole string as a normal event first, and after that it looks if there's a priority setting in it and uses the new string with priority for parsing and applies the priority afterwards.Therefore, this change adds the method
SkriptEvent#isEventPrioritySupport
(by default overridden bySelfRegisteringSkriptEvent
to return false), so addons can override this method if needed. I've also changed SkriptEvent#getEventPriority so that it returns the right value when called fromSkriptEvent#init
.A quick test with a modified skript-reflect version shows everything still works:
![image](https://user-images.githubusercontent.com/29547183/149803015-f47ecb02-3970-4e0d-b026-80788f0c8283.png)
Target Minecraft Versions: any
Requirements: none
Related Issues: #3852