Save controller plugin data on the save hook (#513)

exp_groups and exp_roles only saved their datastores on shutdown, and
exp_scenario saved the player store but not the feature store on the
save hook. The controller runs the save hook on its autosave interval,
so a crash or kill lost every change since the controller started.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
BastiaanandClaude Opus 5.5 authored and GitHub committed 2026-10-25 21:57:21 +00:00
1 parent 82abc2c332
commit 20ca539af3
5 files changed
+33 -5

No files matched your search

+3 -2
View File
@@ -55,13 +55,14 @@ export class ControllerPlugin {
controller.handle(messages.AssignmentUpdateRequest, plugin.handleAssignmentUpdateRequest.bind(plugin));
const hooks = controller.hooks;
hooks.shutdown.attach(plugin.name, plugin.onShutdown.bind(plugin));
hooks.save.attach(plugin.name, plugin.onSave.bind(plugin));
hooks.shutdown.attach(plugin.name, plugin.onSave.bind(plugin));
hooks.controllerConfigFieldChanged.attach(plugin.name, plugin.onControllerConfigFieldChanged.bind(plugin));
hooks.playerEvent.attach(plugin.name, plugin.onPlayerEvent.bind(plugin));
return plugin;
}
async onShutdown() {
async onSave() {
await this.roleMeta.save();
}