Replace the manual isCurrentEvent checks in favor of ERS#8529
Replace the manual isCurrentEvent checks in favor of ERS#8529NotroDev wants to merge 13 commits intoSkriptLang:dev/patchfrom
isCurrentEvent checks in favor of ERS#8529Conversation
src/main/java/ch/njol/skript/effects/EffHidePlayerFromServerList.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Efnilite <35348263+Efnilite@users.noreply.github.com>
src/main/java/ch/njol/skript/effects/EffHidePlayerFromServerList.java
Outdated
Show resolved
Hide resolved
src/main/java/ch/njol/skript/effects/EffHidePlayerFromServerList.java
Outdated
Show resolved
Hide resolved
…List Co-authored-by: SirSmurfy2 <82696841+Absolutionism@users.noreply.github.com>
You could add support for this while you're at it, It's pretty simple. Just start a retaining log handler before |
It is worth noting that ERS checks occur before |
I'll try to look into it when I have some free time, so I think this PR can stay open for a while |
|
Hey, I've gotten some work done. First, after @Absolutionism's comment, I realized that most of the "paper event exists" checks were redundant. I cleaned them up and added ERS where possible. The changes in next I'll try to expand the ERS usage as discussed above |
Absolutionism
left a comment
There was a problem hiding this comment.
Just some coding convention touch ups
Co-authored-by: SirSmurfy2 <82696841+Absolutionism@users.noreply.github.com>
…ub.com/NotroDev/Skript into patch/event-restricted-syntax-refactor
Problem
The PR introducing the
EventRestrictedSyntaxinterface didn't replace the usages in the legacy classes, so they still used the manualisCurrentEventchecks in theirinit()methods. While it works pretty much the same, the ERS approach is cleaner and can be used to extract the info about supported events.Solution
I just went over all the classes where the old approach was still used and replaced it with the ERS implementation.
Testing Completed
I didn't do any manual testing (as that's a technical change) but it compiles and passes the
quickTest.Supporting Information
The ERS interface is pretty straightforward so I could replace only the most basic checks.
For example, the
ExprProtocolVersionclass checks for the existence of the paper event first:And I don't think I can recreate this behavior properly in ERS without compromising the proper error messages (and I didn't want to expand the ERS logic without discussion)
The only exception is
EffHidePlayerFromServerListwhere I used this approach:except in that case I believe the
PaperServerListPingEventis redundant anyway (and because it inherits from theServerListPingEvent, theisCurrentEventwhich usesisAssignableFromunder the hood, will pass it anyway)There are also much more complicated examples in the Skript codebase where the supported events change based on the pattern or other circumstances, so the ERS couldn't be implemented.
PS. I can't guarantee that I've found all the usages that could be replaced :P
Completes: none
Related: none
AI assistance: none (i did it fully by hand because I thought there would be far fewer legacy usages...)