EngineHub / CommandHelper

Rapid scripting and command aliases for Minecraft owners
https://methodscript.com
Other
119 stars 71 forks source link

Add first version of deep bind compilation checks. #1301

Closed LadyCailin closed 2 years ago

LadyCailin commented 2 years ago

All events will need to be rewritten to fully support this, and from a framework perspective, there are still missing items (particularly around generation of the docs) but what is here so far does work.

In general, this changes the format of the prefilters from a procedural to a declarative format. This makes specifying the event a bit more cumbersome, but at a huge payoff. For one, the docs and filtering are harder to screw up, but primarily, this should be a substantially better performing pattern. Previously, many of the events used a PrefilterNonMatchException to signal that the prefilter doesn't match. This was less code, but throwing exceptions is substantially more expensive than simply returning a false boolean. However, doing a procedural approach and only dealing with booleans would be even more code than this new approach is, so this is a good balance between performance and development effort.

Remaining work to be done is to obviously convert every event, but this can be done at a slower pace in the future. For the framework, the remaining item is to add a way to provide the prefilter description in the event declaration, and then using that in the documentation generation as well.

The compilation works, but the new mechanism for checking the prefilters at runtime has not been tested, and this PR should not be merged in until it has.