mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
Refactor away the config group concept and simplyfy the way config fields are defined. Fields are defined directly as properties of the static field fieldDefinitions on the class itself with a separate interface to declare the types of fields. This makes it possible to easily make accessing the config fields type checked in a way that lets plugins extend the interfaces with their own config options by adding additional fields to the interface via declation merging.
62 lines
1.7 KiB
TypeScript
62 lines
1.7 KiB
TypeScript
import * as lib from "@clusterio/lib";
|
|
import * as messages from "./messages";
|
|
|
|
declare module "@clusterio/lib" {
|
|
export interface ControllerConfigFields {
|
|
"subspace_storage.division_method": "simple" | "dole" | "neural_dole";
|
|
"subspace_storage.log_item_transfers": boolean;
|
|
}
|
|
export interface InstanceConfigFields {
|
|
"subspace_storage.log_item_transfers": boolean;
|
|
}
|
|
}
|
|
|
|
lib.definePermission({
|
|
name: "subspace_storage.storage.view",
|
|
title: "View Subspace Storage",
|
|
description: "View the items and fluids stored in the shared subspace.",
|
|
grantByDefault: true,
|
|
});
|
|
|
|
export default {
|
|
name: "subspace_storage",
|
|
title: "Subspace Storage",
|
|
description: "Provides shared storage across instances for the Subspace Storage mod",
|
|
instanceEntrypoint: "dist/plugin/instance",
|
|
instanceConfigFields: {
|
|
"subspace_storage.log_item_transfers": {
|
|
title: "Log Item Transfers",
|
|
description: "Spam host console with item transfers done.",
|
|
type: "boolean",
|
|
initialValue: false,
|
|
},
|
|
},
|
|
|
|
controllerEntrypoint: "dist/plugin/controller",
|
|
controllerConfigFields: {
|
|
"subspace_storage.division_method": {
|
|
title: "Division Method",
|
|
description: "Method for dividing resource requests between instances.",
|
|
type: "string",
|
|
enum: ["simple", "dole", "neural_dole"],
|
|
initialValue: "simple",
|
|
},
|
|
"subspace_storage.log_item_transfers": {
|
|
title: "Log Item Transfers",
|
|
description: "Spam controller console with item transfers done.",
|
|
type: "boolean",
|
|
initialValue: false,
|
|
},
|
|
},
|
|
|
|
messages: [
|
|
messages.PlaceEvent,
|
|
messages.RemoveRequest,
|
|
messages.GetStorageRequest,
|
|
messages.UpdateStorageEvent,
|
|
messages.SetStorageSubscriptionRequest,
|
|
],
|
|
webEntrypoint: "./web",
|
|
routes: ["/storage"],
|
|
} satisfies lib.PluginDeclaration;
|