Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make event priority parsing more flexible #4502

Merged

Conversation

TPGamesNL
Copy link
Member

@TPGamesNL TPGamesNL commented Jan 14, 2022

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 by SelfRegisteringSkriptEvent 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 from SkriptEvent#init.

A quick test with a modified skript-reflect version shows everything still works:
image

on join:
	broadcast "normal"
on join with priority highest:
	broadcast "highest"
on join with priority lowest:
	broadcast "lowest"
on join with priority low:
	broadcast "low"

import:
	org.bukkit.event.player.PlayerJoinEvent

on PlayerJoinEvent:
	broadcast "ref normal"
on PlayerJoinEvent with priority highest:
	broadcast "ref highest"
on PlayerJoinEvent with priority lowest:
	broadcast "ref lowest"
on PlayerJoinEvent with priority low:
	broadcast "ref low"

Target Minecraft Versions: any
Requirements: none
Related Issues: #3852

@TPGamesNL TPGamesNL added the enhancement Feature request, an issue about something that could be improved, or a PR improving something. label Jan 14, 2022
TPGamesNL added a commit to SkriptLang/skript-reflect that referenced this pull request Jan 14, 2022
Since Skript 2.6 listeners with priority with the 'with priority' syntax weren't registered with that priority, this also makes it so that these error instead of being silenty wrong.
These will work again after SkriptLang/Skript#4502, or switch syntax ('at priority X' or 'on priority X' instead of 'with priority X')
@TPGamesNL TPGamesNL marked this pull request as draft January 16, 2022 17:34
@TPGamesNL TPGamesNL changed the title Attempt event parse without priority first Make event priority parsing more flexible Jan 17, 2022
@TPGamesNL TPGamesNL marked this pull request as ready for review January 17, 2022 16:04
@TPGamesNL TPGamesNL merged commit 3a54b2f into SkriptLang:master Jan 17, 2022
@TPGamesNL TPGamesNL deleted the fix/event-priority-parsing-reflect branch January 17, 2022 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request, an issue about something that could be improved, or a PR improving something.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants