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.
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import * as lib from "@clusterio/lib";
|
|
import * as messages from "./messages";
|
|
|
|
declare module "@clusterio/lib" {
|
|
export interface InstanceConfigFields {
|
|
"player_auth.load_plugin": boolean;
|
|
}
|
|
export interface ControllerConfigFields {
|
|
"player_auth.code_length": number;
|
|
"player_auth.code_timeout": number;
|
|
}
|
|
}
|
|
|
|
export default {
|
|
name: "player_auth",
|
|
title: "Player Auth",
|
|
description: "Provides authentication to the cluster via logging into a Factorio server.",
|
|
controllerEntrypoint: "dist/plugin/controller",
|
|
instanceEntrypoint: "dist/plugin/instance",
|
|
webEntrypoint: "./web",
|
|
controllerConfigFields: {
|
|
"player_auth.code_length": {
|
|
title: "Code Length",
|
|
description: "Length in characters of the generated codes.",
|
|
type: "number",
|
|
initialValue: 6,
|
|
},
|
|
"player_auth.code_timeout": {
|
|
title: "Code Timeout",
|
|
description: "Time in seconds for the generated codes to stay valid.",
|
|
type: "number",
|
|
initialValue: 120,
|
|
},
|
|
},
|
|
|
|
messages: [
|
|
messages.FetchPlayerCodeRequest,
|
|
messages.SetVerifyCodeRequest,
|
|
],
|
|
} satisfies lib.PluginDeclaration;
|