mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 07:33:12 +09:00
Remove config groups
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.
This commit is contained in:
1 parent
96210373f3
commit
e74065a493
35 files changed
+1259
-2090
No files matched your search
@@ -196,7 +196,7 @@ export class ControllerPlugin extends BaseControllerPlugin {
|
||||
let count = dole.doleDivider({
|
||||
object: { name: item.name, count: item.count, instanceId, instanceName },
|
||||
items: this.items,
|
||||
logItemTransfers: this.controller.config.get("subspace_storage.log_item_transfers") as boolean,
|
||||
logItemTransfers: this.controller.config.get("subspace_storage.log_item_transfers"),
|
||||
logger: this.logger,
|
||||
});
|
||||
if (count > 0) {
|
||||
|
||||
@@ -1,37 +1,15 @@
|
||||
import * as lib from "@clusterio/lib";
|
||||
import * as messages from "./messages";
|
||||
|
||||
class ControllerConfigGroup extends lib.PluginConfigGroup {}
|
||||
ControllerConfigGroup.defaultAccess = ["controller", "host", "control"];
|
||||
ControllerConfigGroup.groupName = "subspace_storage";
|
||||
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 lib.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();
|
||||
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",
|
||||
@@ -45,10 +23,31 @@ export default {
|
||||
title: "Subspace Storage",
|
||||
description: "Provides shared storage across instances for the Subspace Storage mod",
|
||||
instanceEntrypoint: "dist/plugin/instance",
|
||||
InstanceConfigGroup,
|
||||
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",
|
||||
ControllerConfigGroup,
|
||||
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,
|
||||
|
||||
Reference in new issue
Block a user