Files
factorio-clusterio/plugins/subspace_storage/info.js
T
Hornwitser 7f8a700716 Refactor message registration and validation
Split up the action of registring an event or request data class to be
decoded by the Link class and the action of registring a handler for
those requests and events.  This moves the validation work from Link
instantiation time to startup initialisation which makes logic errors
fail on startup instead of failing instantiation of the link when a
connection attempt is made.

Additionally implement a partial validation logic for messages received
using the newly refactored message registration.  This unfortunately
ended up merged with the registration refactor.
2023-06-03 16:47:47 +02:00

71 lines
2.1 KiB
JavaScript

"use strict";
const { libConfig, libUsers } = require("@clusterio/lib");
const messages = require("./messages");
class ControllerConfigGroup extends libConfig.PluginConfigGroup {}
ControllerConfigGroup.defaultAccess = ["controller", "host", "control"];
ControllerConfigGroup.groupName = "subspace_storage";
ControllerConfigGroup.define({
name: "autosave_interval",
title: "Autosave Interval",
description: "Interval the storage is autosaved at in seconds.",
type: "number",
initial_value: 60,
});
ControllerConfigGroup.define({
name: "division_method",
title: "Division Method",
description: "Method for dividing resource requests between instances.",
type: "string",
enum: ["simple", "dole", "neural_dole"],
initial_value: "simple",
});
ControllerConfigGroup.define({
name: "log_item_transfers",
title: "Log Item Transfers",
description: "Spam controller console with item transfers done.",
type: "boolean",
initial_value: false,
});
ControllerConfigGroup.finalize();
class InstanceConfigGroup extends libConfig.PluginConfigGroup {}
InstanceConfigGroup.defaultAccess = ["controller", "host", "control"];
InstanceConfigGroup.groupName = "subspace_storage";
InstanceConfigGroup.define({
name: "log_item_transfers",
title: "Log Item Transfers",
description: "Spam host console with item transfers done.",
type: "boolean",
initial_value: false,
});
InstanceConfigGroup.finalize();
libUsers.definePermission({
name: "subspace_storage.storage.view",
title: "View Subspace Storage",
description: "View the items and fluids stored in the shared subspace.",
grantByDefault: true,
});
module.exports = {
name: "subspace_storage",
title: "Subspace Storage",
description: "Provides shared storage across instances for the Subspace Storage mod",
instanceEntrypoint: "instance",
InstanceConfigGroup,
controllerEntrypoint: "controller",
ControllerConfigGroup,
messages: [
messages.PlaceEvent,
messages.RemoveRequest,
messages.GetStorageRequest,
messages.UpdateStorageEvent,
messages.SetStorageSubscriptionRequest,
],
webEntrypoint: "./web",
routes: ["/storage"],
};