mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-23 00:13:13 +09:00
Invoke the config changed hook for every field
The fieldChanged handler repeated the hook invoke in each branch, and factorio.shutdown_timeout had no invoke at all, so plugins were never told about a change to it. Do the field specific side effect, then invoke the hook once for every field. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
96362a2835
commit
a76b742294
2 files changed
+32
-9
No files matched your search
@@ -200,24 +200,18 @@ export default class Instance extends lib.Link {
|
||||
this.hooks = new InstanceHooks(this.logger);
|
||||
|
||||
this._configFieldChanged = (field: string, curr: unknown, prev: unknown) => {
|
||||
let hook = () => this.hooks.instanceConfigFieldChanged.invoke(field, curr, prev);
|
||||
|
||||
if (field === "factorio.shutdown_timeout") {
|
||||
this.server.shutdownTimeoutMs = curr as number * 1000;
|
||||
} else if (field === "factorio.max_concurrent_commands") {
|
||||
this.server.maxConcurrentCommands = curr as number;
|
||||
} else if (field === "factorio.settings") {
|
||||
this._applyWhenRunning(
|
||||
"server settings", () => this.updateFactorioSettings(curr as any, prev as any)
|
||||
);
|
||||
hook();
|
||||
} else if (field === "factorio.enable_whitelist") {
|
||||
this._applyWhenRunning("whitelist", () => this.updateFactorioWhitelist(curr as any));
|
||||
hook();
|
||||
} else {
|
||||
if (field === "factorio.max_concurrent_commands") {
|
||||
this.server.maxConcurrentCommands = curr as number;
|
||||
}
|
||||
hook();
|
||||
}
|
||||
this.hooks.instanceConfigFieldChanged.invoke(field, curr, prev);
|
||||
};
|
||||
this.config.on("fieldChanged", this._configFieldChanged);
|
||||
|
||||
|
||||
Reference in new issue
Block a user