Files
factorio-clusterio/plugins/inventory_sync/info.ts
T
Hornwitser ffe5040644 Implement autosaving of data held in memory
Add controller.autosave_interval config that specifies the frequency
which controller config, hosts, instances, users, mod packs and plugin
specific data which is held in memory should be automatically flushed to
disk if they have changed since the last time they were saved.  This
prevents data loss in the event of a server crash.

Plugins can use the onSaveData hook to save its own data at the same
time as the controller does and this obsoletes making an autosave
interval in the plugin.

Resolves #523.
2023-11-29 20:18:50 +01:00

57 lines
1.7 KiB
TypeScript

import * as lib from "@clusterio/lib";
import * as messages from "./messages";
class ControllerConfigGroup extends lib.PluginConfigGroup { }
ControllerConfigGroup.defaultAccess = ["controller", "host", "control"];
ControllerConfigGroup.groupName = "inventory_sync";
ControllerConfigGroup.define({
name: "player_lock_timeout",
title: "Player Lock Timeout",
description:
"Time in seconds before the lock on a player inventory expires after an instance stops or is disconnected",
type: "number",
initial_value: 60,
});
ControllerConfigGroup.finalize();
class InstanceConfigGroup extends lib.PluginConfigGroup { }
InstanceConfigGroup.defaultAccess = ["controller", "host", "control"];
InstanceConfigGroup.groupName = "inventory_sync";
InstanceConfigGroup.define({
name: "rcon_chunk_size",
title: "Rcon inventory chunk size",
description: "Divide inventories into multiple chunks before sending with rcon to prevent blocking the pipe",
type: "number",
initial_value: 1000,
});
InstanceConfigGroup.finalize();
lib.definePermission({
name: "inventory_sync.inventory.view",
title: "View player inventories",
description: "View player inventories",
grantByDefault: true,
});
export default {
name: "inventory_sync",
title: "Inventory sync",
description: "Synchronizes players inventories between instances",
instanceEntrypoint: "dist/plugin/instance",
InstanceConfigGroup,
controllerEntrypoint: "dist/plugin/controller",
ControllerConfigGroup,
messages: [
messages.AcquireRequest,
messages.ReleaseRequest,
messages.UploadRequest,
messages.DownloadRequest,
messages.DatabaseStatsRequest,
],
webEntrypoint: "./web",
routes: ["/inventory"],
} satisfies lib.PluginDeclaration;