Installation command
!!MCDR plugin install cfgcmdAuthor
Repository
Homepage
Synced at
...
Last update
...
Latest version
Total downloads
253
Back to catalogue
configCommand / cfgcmd
Still translated by gpt-4o
Use MCDR commands in the game to modify configurations of other plugins/Mods!
Version 1.3.1 supports online editor
Permissions
Currently, the plugin allows all players with permissions to modify the configuration (MCDR level 4). This plugin can modify all files that the user running the MCDR process has access to (especially root), so please control permissions or run the server in a container.
Commands
!!cfg env <path, starting from the MCDR root path, can be absolute/relative path> <config file> [optional: reader type]: Set the target file modified by the executor!!cfg quit: Clear the executor's target file!!cfg write: Write to the target file!!cfg reload: Reload the target file (overwrites all previous modifications)!!cfg info: View file information
!!cfg set <key> <value>: Set a key-value pair, where<key>uses.to separate paths in the configuration tree (see the example below). This command does not support relative paths like..in thekey. See the "Types" section below for types.!!cfg setTyped <key> <type> <value>: See the "Types" section below. If the value cannot be interpreted as the specified type, it will default toSTRING.!!cfg rm <key>: Delete the key's content!!cfg mv <sourceKey> <destKey>: Move or rename!!cfg cp <sourceKey> <destKey>: Copy and paste!!cfg cd <key>: Since configuration files are tree-structured, this command provides a file-system-likecdoperation. Not available when the reader isplain.!!cfg ls [optional: page] [require prior key]: View the content of the current object. When the reader isplain`, the entire file is printed. Each page contains 10 lines.!!cfg lsLong [required: page] [optional: lines per page] [require prior key]: Same as the previous command
!!cfg lsDir <path>: View a list of files starting from the MCDR root directory!!cfg rmFile <file>: Delete a file (cannot be undone)!!cfg touchFile <file>: Create an empty file
!!cfg editor: Open the online editor for the current file, requires settingenableCloudtotrue!!cfg editorApply: Synchronize the modified configuration file from the cloud!!cfg editorDelete: Delete the cloud session
If upgrading from version
1.3.1or below, you need to manually addenableCloud: trueto your configuration file to use the online editor.
After executing
!!cfg env ..., the file will not be locked
Executing!!cfg infowill display the current file information
Executing!!cfg lswill print the content of the object where the pointer is located
The reader is determined by the file extension. Files with no extension or unknown extensions will use theplainreader
When the reader isplain, the<key>parameter specifies the line number
If the<key>contains spaces and is followed by other parameters, wrap it in double quotes. Use\to escape. See QuotableText
Number Types
setTyped can specify the type of a value. The following types are available, and some types have special behaviors:
STRING: Basic stringINT: Number, including floating-point numbers (float)BOOL: Boolean value, case-insensitive, but must be eitherT/True(true) orF/False(false)LIST: ListOBJECT: JSObject, Pythondict, YAMLmappingAUTO: This type directly uses thesetcommand
Special Behavior for LIST and OBJECT
LIST
The input value is split by commas, and you can escape commas with \ to avoid incorrect splitting. After splitting, each item will be type-inferred and a list will be created. If the value is empty, an empty list is created.
OBJECT
Similar to LIST, the input value is split by commas and then split into key-value pairs using :. Commas can also be escaped with \ to avoid incorrect splitting. The items will be type-inferred (both keys and values) and an OBJECT will be created. If the value is empty, an empty OBJECT will be created.
It is not recommended to use
setTyped OBJECT ..., as it can encounter input restrictions in chat. It is better to use it only for creating emptyOBJECTs.
Type Inference
All inferred types follow a common logic:
- If the value doesn't exist or is
None(case-sensitive), it will start automatic inference, otherwise it will use the existing type. - If the value (in uppercase) matches one of
T,TRUE,F, orFALSE, it is a boolean value. - If the value contains non-numeric characters (other than decimal points, negative signs, or double quotes), it is a string.
- If the value is enclosed in double quotes, it is a string representation of a number. Remove the surrounding double quotes and proceed to step 5.
- If it consists only of numbers (including possible decimals or signs), it is considered a number.
- Otherwise, it is a string.
LISTandOBJECTare not involved in this inference process, so automatic inference won't result inLISTorOBJECT.
Example
Original configuration file:
1 {
2 "foo": 123,
3 "bar": {
4 "barFoo": "?",
5 "barBar": {
6 "barBarFoo": 456
7 }
8 },
9 "buzz": [
10 "wangyupu","zzfx1166"
11 ]
12 }
Commands (in order):
!!cfg env "config/foo/" bar.json: Open the file!!cfg set foo 1231: Set the value on line 2 to 1231- `!!cfg set bar.barFoo "!": Set the value on line 4 to "!"
!!cfg rm buzz.1: Remove the second item in the list on line 10 (0-based index)!!cfg cd bar.barBar: Change the pointer to the object on line 5!!cfg set barBarFoo 789: Set the value on line 6 to 789!!cfg write: Write the file!!cfg quit: Exit the file
Modified configuration file:
1 {
2 "foo": 1231,
3 "bar": {
4 "barFoo": "!",
5 "barBar": {
6 "barBarFoo": 789
7 }
8 },
9 "buzz": [
10 "wangyupu"
11 ]
12 }
Plugin Configuration
ownerPlayer: PlayerName
cfgCmdPermission: 4
allowModifyConfig: true
allowOutBound: false
enableLog: true
onlyOwnerPlayer: false
ownerPlayer: The player specified here bypasses all security controls. Leave it empty to apply permission control to all authorized players.allowModifyConfig: Determines whether the configuration of this plugin (cfgcmd) can be modified.allowOutBound: Determines whether accessing files outside the MCDR root path is allowed. When set tofalse, only files within the MCDR path are accessible.enableLog: Determines whether to enable logging, which will be saved in the MCDR root path/logs/cfgcmdLogs/--- _.log.
onlyOwnerPlayer: Determines whether only the specifiedownerPlayeris allowed to use this plugin.
allowModifyConfigdefaults totrueto allow administrators to safely configure the plugin when they cannot access the backend. It is recommended to manually set it tofalseafter installation.
Supported Configuration File Formats
jsonyaml(yml)toml- Plain text
Introduction source: README_en.md