mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-15 15:24:52 +09:00
Adds an inventory_sync.sync_<component> instance config field for the controller, force, appearance, inventories, logistics, quick bar, settings and recipe notifications. All default to on, which keeps the current behaviour. A component which is off on an instance is left alone there and its fields are not stored from that instance. The controller merges each upload with the stored data using the uploading instance's config, the instance strips the fields from downloads before sending them over RCON, and the scenario is told the enabled set on start and when it changes so it can skip serializing them and skip the steps which replace the character. The controller is only synced together with the inventories, as switching controller can destroy the character holding them. Without the controller synced the player gets back the controller they had on the instance, only character inventories move between instances, and a player without a character keeps their inventory. Closes #968 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
128 lines
3.6 KiB
TypeScript
128 lines
3.6 KiB
TypeScript
import * as lib from "@clusterio/lib";
|
|
import * as messages from "./messages.js";
|
|
|
|
declare module "@clusterio/lib" {
|
|
export interface InstanceConfigFields {
|
|
"player_sync.rcon_chunk_size": number;
|
|
"player_sync.sync_controller": boolean;
|
|
"player_sync.sync_force": boolean;
|
|
"player_sync.sync_appearance": boolean;
|
|
"player_sync.sync_inventories": boolean;
|
|
"player_sync.sync_logistics": boolean;
|
|
"player_sync.sync_quick_bar": boolean;
|
|
"player_sync.sync_settings": boolean;
|
|
"player_sync.sync_recipe_notifications": boolean;
|
|
}
|
|
export interface ControllerConfigFields {
|
|
"player_sync.player_lock_timeout": number;
|
|
}
|
|
export interface Permissions {
|
|
"player_sync.inventory.view": never;
|
|
}
|
|
}
|
|
|
|
export const plugin: lib.PluginDeclaration = {
|
|
name: "player_sync",
|
|
title: "Player sync",
|
|
description: "Synchronizes player inventories and settings between instances",
|
|
migrationEntrypoint: "dist/node/migrations.js",
|
|
|
|
instanceEntrypoint: "dist/node/instance.js",
|
|
instanceConfigFields: {
|
|
"player_sync.rcon_chunk_size": {
|
|
title: "Rcon inventory chunk size",
|
|
description:
|
|
"Divide inventories into chunks of this size before sending with rcon to prevent blocking the pipe",
|
|
type: "number",
|
|
initialValue: 1000,
|
|
},
|
|
"player_sync.sync_controller": {
|
|
title: "Sync controller",
|
|
description:
|
|
"Sync whether the player is a character, god or spectator, their respawn timer and cheat " +
|
|
"mode. Only synced while inventories are synced too.",
|
|
type: "boolean",
|
|
initialValue: true,
|
|
},
|
|
"player_sync.sync_force": {
|
|
title: "Sync force",
|
|
description: "Sync the force the player is on.",
|
|
type: "boolean",
|
|
initialValue: true,
|
|
},
|
|
"player_sync.sync_appearance": {
|
|
title: "Sync appearance",
|
|
description: "Sync the player colour, chat colour and tag.",
|
|
type: "boolean",
|
|
initialValue: true,
|
|
},
|
|
"player_sync.sync_inventories": {
|
|
title: "Sync inventories",
|
|
description:
|
|
"Sync the character and god inventories, character bonuses and crafting queue. Without the " +
|
|
"controller synced only the inventory of a character is synced.",
|
|
type: "boolean",
|
|
initialValue: true,
|
|
},
|
|
"player_sync.sync_logistics": {
|
|
title: "Sync logistics",
|
|
description: "Sync the personal logistic requests.",
|
|
type: "boolean",
|
|
initialValue: true,
|
|
},
|
|
"player_sync.sync_quick_bar": {
|
|
title: "Sync quick bar",
|
|
description: "Sync the quick bar.",
|
|
type: "boolean",
|
|
initialValue: true,
|
|
},
|
|
"player_sync.sync_settings": {
|
|
title: "Sync settings",
|
|
description: "Sync the shortcut toggles, game view settings and flashlight.",
|
|
type: "boolean",
|
|
initialValue: true,
|
|
},
|
|
"player_sync.sync_recipe_notifications": {
|
|
title: "Sync recipe notifications",
|
|
description: "Sync which new recipe notifications have been seen.",
|
|
type: "boolean",
|
|
initialValue: true,
|
|
},
|
|
},
|
|
|
|
controllerEntrypoint: "dist/node/controller.js",
|
|
controllerConfigFields: {
|
|
"player_sync.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",
|
|
initialValue: 60,
|
|
},
|
|
},
|
|
|
|
features: [
|
|
"SavePatching",
|
|
"ScriptCommands",
|
|
],
|
|
|
|
messages: [
|
|
messages.AcquireRequest,
|
|
messages.ReleaseRequest,
|
|
messages.UploadRequest,
|
|
messages.DownloadRequest,
|
|
messages.DatabaseStatsRequest,
|
|
],
|
|
permissions: [
|
|
{
|
|
name: "player_sync.inventory.view",
|
|
title: "View player inventories",
|
|
description: "View player inventories",
|
|
grantByDefault: true,
|
|
},
|
|
],
|
|
webEntrypoint: "./web",
|
|
routes: ["/inventory"],
|
|
};
|