Files
ILLISISandClaude Opus 5.5 b8c1e89dff Forward player data to the instance a player is switching to
An upload can carry destinationInstanceId. Once the upload is stored,
the controller sends the stored data, the upload merged with its copy,
in a PrefetchEvent to that instance, if it is another running instance
with player_sync enabled. No lock is taken or released. A failed send is
logged and doesn't fail the upload.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-20 12:23:13 +11:00

141 lines
4.0 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;
"player_sync.inventory.modify": 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, cheat mode " +
"and god inventory. 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 color, chat color and tag.",
type: "boolean",
initialValue: true,
},
"player_sync.sync_inventories": {
title: "Sync inventories",
description:
"Sync the character inventories, character bonuses and crafting queue. Without the " +
"controller synced a player without a character keeps their local inventory.",
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",
ctlEntrypoint: "dist/node/ctl.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.PrefetchEvent,
messages.DatabaseStatsRequest,
messages.ListPlayersRequest,
messages.GetPlayerDataRequest,
messages.SetPlayerDataRequest,
messages.DeletePlayerDataRequest,
messages.ForceReleaseRequest,
],
permissions: [
{
name: "player_sync.inventory.view",
title: "View player inventories",
description: "View player inventories",
grantByDefault: true,
},
{
name: "player_sync.inventory.modify",
title: "Modify player inventories",
description: "Replace, delete and release the lock on player inventories stored on the controller",
},
],
webEntrypoint: "./web",
routes: ["/inventory"],
};