mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 23:30:41 +09:00
Expose Slave to instance plugins
Allow the slave object to be accessed by instance plugins through the this.slave property.
This commit is contained in:
1 parent
3ff5e630ca
commit
9a4a535add
2 files changed
+26
-4
No files matched your search
@@ -50,7 +50,7 @@ class Instance extends link.Link{
|
||||
});
|
||||
}
|
||||
|
||||
async init(pluginInfos) {
|
||||
async init(pluginInfos, slave) {
|
||||
await this.server.init();
|
||||
|
||||
// load plugins
|
||||
@@ -62,7 +62,7 @@ class Instance extends link.Link{
|
||||
// require plugin class and initialize it
|
||||
let pluginLoadStarted = Date.now();
|
||||
let { InstancePlugin } = require(`./plugins/${pluginInfo.name}/${pluginInfo.instanceEntrypoint}`);
|
||||
let instancePlugin = new InstancePlugin(pluginInfo, this);
|
||||
let instancePlugin = new InstancePlugin(pluginInfo, this, slave);
|
||||
await instancePlugin.init();
|
||||
this.plugins.set(pluginInfo.name, instancePlugin);
|
||||
plugin.attachPluginMessages(this, pluginInfo, instancePlugin);
|
||||
@@ -543,7 +543,7 @@ class Slave extends link.Link {
|
||||
let instance = new Instance(
|
||||
connectionClient, instanceInfo.path, this.config.get("slave.factorio_directory"), instanceInfo.config
|
||||
);
|
||||
await instance.init(this.pluginInfos);
|
||||
await instance.init(this.pluginInfos, this);
|
||||
|
||||
// XXX: race condition on multiple simultanious calls
|
||||
this.instanceConnections.set(instanceId, instanceConnection);
|
||||
|
||||
Reference in new issue
Block a user