You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+57-16Lines changed: 57 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,20 @@ This module lets you curate the set of chat commands that selected accounts can
4
4
5
5
## Capabilities
6
6
- Manage a list of account IDs controlled by the module.
7
-
- Assign a shared default GM level and default command list for those accounts.
7
+
- Define reusable presets with specific GM levels and command lists.
8
+
- Assign presets to accounts for consistent configuration management.
9
+
- Assign a shared default GM level and default command list for accounts without presets.
8
10
- Override the GM level or allowed commands per account.
9
11
- Allow commands that normally require a higher security level when they are explicitly whitelisted.
10
12
- Always allow commands that require security level `SEC_PLAYER` (0).
11
13
14
+
## Configuration Precedence
15
+
The module follows a clear precedence hierarchy when resolving the effective configuration for each account:
16
+
17
+
1.**Default settings** (lowest priority): `GmCommandsModule.DefaultLevel` and `GmCommandsModule.DefaultCommands`
18
+
2.**Preset settings**: If a preset is assigned to an account via `GmCommandsModule.Account.<AccountId>.Preset`, its level and commands override the defaults
19
+
3.**Per-account overrides** (highest priority): `GmCommandsModule.Account.<AccountId>.Level` and `GmCommandsModule.Account.<AccountId>.Commands` override everything else
20
+
12
21
## Configuration Files
13
22
The module looks for its configuration in both `modules/mod_gm_commands.conf.dist` and `modules/mod_gm_commands.conf` inside your server configuration directory (for example `env/dist/etc/modules/`).
14
23
@@ -22,12 +31,19 @@ When the server starts (or the config is reloaded), the module reads `.conf.dist
22
31
-`GmCommandsModule.DefaultLevel`: GM level applied to managed accounts that do not define their own level. Clamped between `SEC_PLAYER (0)` and `SEC_ADMINISTRATOR (3)`.
23
32
-`GmCommandsModule.DefaultCommands`: Comma-separated list of commands granted to managed accounts that do not define their own command list. Commands that require level 0 are still automatically available even if they are not listed.
24
33
25
-
### Per-Account Overrides
26
-
Use the following keys to override defaults for a specific account, replacing `<AccountId>` with the numeric ID:
27
-
-`GmCommandsModule.Account.<AccountId>.Level`
28
-
-`GmCommandsModule.Account.<AccountId>.Commands`
34
+
### Presets
35
+
Presets allow you to define reusable configurations that can be assigned to multiple accounts:
36
+
-`GmCommandsModule.Presets`: Comma-separated list of preset names.
37
+
-`GmCommandsModule.Preset.<PresetName>.Level`: GM level for this preset.
38
+
-`GmCommandsModule.Preset.<PresetName>.Commands`: Comma-separated list of commands for this preset.
29
39
30
-
Both files (`mod_gm_commands.conf.dist` and `mod_gm_commands.conf`) are scanned, so you may define an override in either place. Values found in the non-`.dist` file take precedence.
40
+
### Account Configuration
41
+
Use the following keys to configure specific accounts, replacing `<AccountId>` with the numeric ID:
42
+
-`GmCommandsModule.Account.<AccountId>.Preset`: Assign a preset to this account. Only one preset per account is allowed.
43
+
-`GmCommandsModule.Account.<AccountId>.Level`: Override the preset or default level for this account (highest priority).
44
+
-`GmCommandsModule.Account.<AccountId>.Commands`: Override the preset or default commands for this account (highest priority).
45
+
46
+
Both files (`mod_gm_commands.conf.dist` and `mod_gm_commands.conf`) are scanned, so you may define configuration in either place. Values found in the non-`.dist` file take precedence.
31
47
32
48
#### Command List Formatting
33
49
Commands are stored in a normalized, lowercase form:
- When a GM account uses a command, the module records the command name and its required security level.
45
61
- If an account is in the managed list and the command requires more than `SEC_PLAYER`, the module checks the whitelist before the core performs its visibility/security check.
46
-
- Whitelisted commands return early from the visibility hook, effectively bypassing the security-level requirement for that account. Non-whitelisted commands continue through the normal core checks and are blocked with “You are not allowed to use this command.”
47
-
- The module logs the resolved default settings and per-account overrides at startup (log channel `modules.gmcommands`) to aid troubleshooting.
62
+
- Whitelisted commands return early from the visibility hook, effectively bypassing the security-level requirement for that account. Non-whitelisted commands continue through the normal core checks and are blocked with "You are not allowed to use this command."
63
+
- The module logs the resolved configuration (defaults → preset → overrides) for each account at startup (log channel `modules.gmcommands`) to aid troubleshooting.
48
64
49
65
## Reloading Configuration
50
66
After editing the configuration, either restart the worldserver or run `.reload config` from a GM account with adequate privileges. The module will re-read both configuration files and log the updated account summaries.
51
67
52
68
## Troubleshooting
53
69
- Ensure the account ID is listed in `GmCommandsModule.AccountIds`; otherwise the account is ignored.
54
-
- Use the full command name (including subcommand structure) in the whitelist. If a command still reports “does not exist,” verify the spelling and normalization.
55
-
- Check the worldserver log for `modules.gmcommands` entries to confirm that the module picked up your overrides.
70
+
- Use the full command name (including subcommand structure) in the whitelist. If a command still reports "does not exist," verify the spelling and normalization.
71
+
- Check the worldserver log for `modules.gmcommands` entries to confirm that the module picked up your presets, assignments, and overrides.
72
+
- If a preset is assigned but the account is not configured as expected, verify that the preset name is listed in `GmCommandsModule.Presets` and that the preset definition exists.
56
73
- Commands that require only `SEC_PLAYER` never need to be listed; if users cannot run them, the issue lies elsewhere (permissions, syntax, etc.).
In this example account 3 keeps security level 1 but can run `character level` and `levelup`, while account 4 inherits the default security level (0) yet receives a custom command list.
100
+
In this example:
101
+
- Account 3 receives the `tv_account` preset (level 1 with limited commands)
102
+
- Account 4 receives the `gm_helper` preset (level 2 with ticket/support commands)
103
+
- Account 5 receives the `tv_account` preset level (1) but has an additional command (`gmannounce`) added to its command list
104
+
105
+
## Development Notes
106
+
The implementation lives in `src/GmCommands.cpp` and exposes a singleton (`sGMCommands`) responsible for:
107
+
- Loading presets and per-account configurations from `sConfigMgr` and the module config files.
108
+
- Building effective configurations by applying precedence rules (defaults → presets → overrides).
109
+
- Normalizing command names and caching per-command required security.
110
+
- Hooking `AllCommandScript` to hide or allow commands based on the configured whitelist.
111
+
112
+
Any changes to the command registry should keep the normalization logic in mind so that configuration values remain compatible.
72
113
73
114
## Development Notes
74
115
The implementation lives in `src/GmCommands.cpp` and exposes a singleton (`sGMCommands`) responsible for:
0 commit comments