mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 23:04:52 +09:00
43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import * as lib from "@clusterio/lib";
|
|
import { BaseControllerPlugin, InstanceInfo } from "@clusterio/controller";
|
|
import { PluginExampleEvent, PluginExampleRequest } from "./messages";
|
|
|
|
export class ControllerPlugin extends BaseControllerPlugin {
|
|
async init() {
|
|
this.controller.handle(PluginExampleEvent, this.handlePluginExampleEvent.bind(this));
|
|
this.controller.handle(PluginExampleRequest, this.handlePluginExampleRequest.bind(this));
|
|
}
|
|
|
|
async onControllerConfigFieldChanged(field: string, curr: unknown, prev: unknown) {
|
|
this.logger.info(`controller::onControllerConfigFieldChanged ${field}`);
|
|
}
|
|
|
|
async onInstanceConfigFieldChanged(instance: InstanceInfo, field: string, curr: unknown, prev: unknown) {
|
|
this.logger.info(`controller::onInstanceConfigFieldChanged ${instance.id} ${field}`);
|
|
}
|
|
|
|
async onSaveData() {
|
|
this.logger.info("controller::onSaveData");
|
|
}
|
|
|
|
async onShutdown() {
|
|
this.logger.info("controller::onShutdown");
|
|
}
|
|
|
|
async onPlayerEvent(instance: InstanceInfo, event: lib.PlayerEvent) {
|
|
this.logger.info(`controller::onPlayerEvent ${instance.id} ${JSON.stringify(event)}`);
|
|
}
|
|
|
|
async handlePluginExampleEvent(event: PluginExampleEvent) {
|
|
this.logger.info(JSON.stringify(event));
|
|
}
|
|
|
|
async handlePluginExampleRequest(request: PluginExampleRequest) {
|
|
this.logger.info(JSON.stringify(request));
|
|
return {
|
|
myResponseString: request.myString,
|
|
myResponseNumbers: request.myNumberArray,
|
|
};
|
|
}
|
|
}
|