Add Scripts Loading/Unloading Events - #8816
Conversation
🔍 Triage ChecklistType
Project
|
Efnilite
left a comment
There was a problem hiding this comment.
i think the current order for calling individual/batch events makes sense, as long as it's documented. looks good 🥇
| public static void register(SyntaxRegistry syntaxRegistry) { | ||
| syntaxRegistry.register(SyntaxRegistry.EXPRESSION, | ||
| SyntaxInfo.Expression.simple(ExprLoadingScripts.class, ExprLoadingScripts::new, Script.class, | ||
| "[all [[of] the]|the] (loading|initializing|enabling) scripts")); |
There was a problem hiding this comment.
maybe you could change the existing loaded script syntax class such that writing loaded scripts uses the scripts from this event?
There was a problem hiding this comment.
yeah I just wasn't sure how to handle someone wanting to obtain all scripts too.
| } | ||
| @Override |
There was a problem hiding this comment.
| } | |
| @Override | |
| } | |
| @Override |
| } | ||
| @Override |
There was a problem hiding this comment.
| } | |
| @Override | |
| } | |
| @Override |
| syntaxRegistry.register(BukkitSyntaxInfos.Event.KEY, BukkitSyntaxInfos.Event.builder(EvtScripts.class, "Scripts Loading") | ||
| .supplier(() -> new EvtScripts(true)) | ||
| .addEvent(ScriptsLoadEvent.class) | ||
| .addPattern("scripts (loading|initializing|enabling)") |
There was a problem hiding this comment.
i think adding a distinction between all scripts and a batch of scripts may increase clarity here. also removes the need for the user to check whether the event contains all scripts. this may also allow this class and EvtScript to be merged which might be nice
Problem
It is not currently possible to detect when any script load/unload occurs (i.e. not the script itself loading/unloading).
Solution
Adds two new ScriptLoader events for "bulk" loads/unloads. This includes the first script load (on server start).
I've also added a new ScriptModule with events to listen to these two ScriptLoader events, with support for obtaining the loaded scripts given the script reflection experiment is enabled.
Testing Completed
basic test + more extensive in-game testing
Supporting Information
There are some parts that need further consideration:
loaded scriptsis not really possible as that already exists, and there needs to be a way to distinguish between the two.Completes:
Related: none
AI assistance: none