mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-21 08:03:13 +09:00
Move base plugins to their respective packages
Move BaseControllerPlugin to controller/src/BaseControllerPlugin.ts Move BaseInstancePlugin to host/src/BaseInstancePlugin.ts Move BaseControlPlugin to ctl/src/BaseCtlPlugin.ts Move BaseWebPlugin to web_ui/src/BaseWebPlugin.ts This solves the circular package dependency problem of the base plugins needing types that are available only in the dependencies to lib.
This commit is contained in:
1 parent
63dc370ea0
commit
808eda0513
51 files changed
+1073
-1060
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import type ControlConnection from "@clusterio/controller/src/ControlConnection";
|
||||
import { BaseControllerPlugin, type ControlConnection } from "@clusterio/controller";
|
||||
|
||||
import fs from "fs-extra";
|
||||
import path from "path";
|
||||
@@ -70,7 +70,7 @@ async function saveDatabase(
|
||||
}
|
||||
}
|
||||
|
||||
export class ControllerPlugin extends lib.BaseControllerPlugin {
|
||||
export class ControllerPlugin extends BaseControllerPlugin {
|
||||
items!: lib.ItemDatabase;
|
||||
itemUpdateRateLimiter!: lib.RateLimiter;
|
||||
itemsLastUpdate!: Map<string, number>;
|
||||
@@ -96,7 +96,7 @@ export class ControllerPlugin extends lib.BaseControllerPlugin {
|
||||
saveDatabase(this.controller.config, this.items, this.logger).catch(err => {
|
||||
this.logger.error(`Unexpected error autosaving items:\n${err.stack}`);
|
||||
});
|
||||
}, this.controller.config.get("subspace_storage.autosave_interval") * 1000);
|
||||
}, this.controller.config.get("subspace_storage.autosave_interval") as number * 1000);
|
||||
|
||||
this.neuralDole = new dole.NeuralDole({ items: this.items });
|
||||
this.doleMagicId = setInterval(() => {
|
||||
@@ -180,7 +180,7 @@ export class ControllerPlugin extends lib.BaseControllerPlugin {
|
||||
}
|
||||
|
||||
} else {
|
||||
let instance = this.controller.instances.get(instanceId);
|
||||
let instance = this.controller.instances!.get(instanceId);
|
||||
let instanceName = instance ? instance.config.get("instance.name") : "unkonwn";
|
||||
|
||||
// use fancy neural net to calculate a "fair" dole division rate.
|
||||
@@ -200,7 +200,7 @@ export class ControllerPlugin extends lib.BaseControllerPlugin {
|
||||
let count = dole.doleDivider({
|
||||
object: { name: item.name, count: item.count, instanceId, instanceName },
|
||||
items: this.items,
|
||||
logItemTransfers: this.controller.config.get("subspace_storage.log_item_transfers"),
|
||||
logItemTransfers: this.controller.config.get("subspace_storage.log_item_transfers") as boolean,
|
||||
logger: this.logger,
|
||||
});
|
||||
if (count > 0) {
|
||||
@@ -230,7 +230,7 @@ export class ControllerPlugin extends lib.BaseControllerPlugin {
|
||||
}
|
||||
|
||||
async handleSetStorageSubscriptionRequest(request: SetStorageSubscriptionRequest, src: lib.Address) {
|
||||
let link = this.controller.wsServer.controlConnections.get(src.id);
|
||||
let link = this.controller.wsServer.controlConnections.get(src.id)!;
|
||||
if (request.storage) {
|
||||
this.subscribedControlLinks.add(link);
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user