Skip to content

Fix legacy event registrations not getting the correct origin class for shared event classes (SimpleEvent) - #8971

Open
eyesniper2 wants to merge 1 commit into
SkriptLang:dev/patchfrom
eyesniper2:patch/fix-syntax-origin-for-legacy-simple-events
Open

eyesniper2 wants to merge 1 commit into
SkriptLang:dev/patchfrom
eyesniper2:patch/fix-syntax-origin-for-legacy-simple-events

Conversation

@eyesniper2

Copy link
Copy Markdown
Contributor

Problem

Third party documentation generation addons like the SkriptHubDocsTool have been unable to tell the origin of events that use the old event registration API and use shared event classes like SimpleEvent. Currently these events either get excluded or get grouped under Skript which isn't accurate. This change fixes this by trying to get the registering class via the stack walker and uses that as the origin instead of passing in a blank string and the shared class which almost always resolves to Skript. This means that tools like the SkriptHubDocsTool, will be able to properly group events that use the legacy event registration API and SimpleEvent to the right addon.

Solution

Within Skript.registerEvent instead of just using the getSyntaxOrigin on the eventClass, this change tries to get the registering class via getRegisteringClass and then uses that class in getSyntaxOrigin. If that fails and returns unknown, we then fallback to the original getSyntaxOrigin(eventClass) call.

getRegisteringClass tries to find the first class that isn't Skript.class since that is the registering class. If we are unable to find anything, we just use the class that was passed in as the fallback.

This calculated origin is then passed into an updated ModernSkriptEventInfo constructor that takes a defined Origin which is how this updated origin makes it to the SkriptHubDocsTool.

Testing Completed

Testing by build this change locally and then running on a local dev server alongside an updated SkriptHubDocsTool to validate that when running "gendocs", Skript's SimpleEvents showed up in the output. I also checked that addons like skRayFall had their SimpleEvent like "On store" not show up in Skript's events. Today with the current SkriptHubDocsTool (1.17), SimpleEvents events are dropped, but with these changes and some changes I have coming for the SkriptHubDocsTool in 1.18 these events all get attributed to the right addons.

All tests passed when running "gradlew clean quickTest"

Supporting Information

N/A


Completes: none
Related: none
AI assistance: Claude Code (Opus 5.5) was used to trace the issue and author this fix. All code was reviewed and validated by hand.

@eyesniper2
eyesniper2 requested review from a team as code owners November 14, 2026 10:44
@eyesniper2
eyesniper2 requested review from APickledWalrus and erenkarakal and removed request for a team November 14, 2026 10:44
@skriptlang-automation skriptlang-automation Bot added needs reviews A PR that needs additional reviews needs triage An issue that hasn't been classified or verified yet labels Nov 14, 2026
@skriptlang-automation

This comment has been minimized.

@skriptlang-automation skriptlang-automation Bot added the bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. label Nov 14, 2026
@skriptlang-automation skriptlang-automation Bot moved this to In Review in 2.17 Releases Nov 14, 2026
@skriptlang-automation skriptlang-automation Bot removed the needs triage An issue that hasn't been classified or verified yet label Nov 14, 2026
@@ -249,8 +249,13 @@ public static final class ModernSkriptEventInfo<E extends SkriptEvent>
private final Origin origin;

public ModernSkriptEventInfo(String name, String[] patterns, Class<E> eventClass, String originClassPath, Class<? extends Event>[] events) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could probably remove this old constructor if it's now unused since this is an internal class

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. needs reviews A PR that needs additional reviews

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants