Skip to content

Commit 3864395

Browse files
committed
Document multiline help bindings
1 parent a46c0d1 commit 3864395

File tree

3 files changed

+227
-0
lines changed

3 files changed

+227
-0
lines changed

docs/matrixshop/bindings-and-ui.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ Bindings:
3636
- `Show-In-Help`:是否出现在 `/ms help`
3737
- `Priority`:冲突时优先级
3838

39+
如果你需要:
40+
41+
- 自定义多行帮助
42+
- 自定义帮助描述键
43+
- 自定义子命令提示键
44+
45+
请继续看:
46+
47+
- [Help、Help-Key 与 Hint-Keys](./bindings-help-and-hints)
48+
3949
## `shopId` 规则
4050

4151
当前实现里,`shopId` 不再依赖 YAML 内部的 `id` 字段,而是直接取:
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
---
2+
title: Help、Help-Key 与 Hint-Keys
3+
description: MatrixShop 中绑定命令的多行帮助、描述键和提示键的配置规则。
4+
---
5+
6+
# Help、Help-Key 与 Hint-Keys
7+
8+
MatrixShop 当前的命令帮助有三层:
9+
10+
1. 固定命令列表
11+
2. `Help-Key`
12+
3. `Help`
13+
14+
其中:
15+
16+
- `Help-Key` 负责“主入口一句话描述”
17+
- `Help` 负责“多行补充说明”
18+
- `Hint-Keys` 负责“某个子动作的提示键”
19+
20+
## 这三个字段写在哪里
21+
22+
### 模块级
23+
24+
适用于没有 `shops/*.yml` 的模块,例如:
25+
26+
- `SystemShop`
27+
- `ChestShop`
28+
- `Cart`
29+
- `Record`
30+
31+
写在:
32+
33+
```yml
34+
Bindings:
35+
Commands:
36+
...
37+
```
38+
39+
### 商店级
40+
41+
适用于带 `shops/*.yml` 的模块,例如:
42+
43+
- `PlayerShop`
44+
- `GlobalMarket`
45+
- `Auction`
46+
- `Transaction`
47+
48+
也写在:
49+
50+
```yml
51+
Bindings:
52+
Commands:
53+
...
54+
```
55+
56+
只是位置在 `shops/*.yml` 里。
57+
58+
## `Help-Key`
59+
60+
这是一个 i18n key,对应主帮助列表中的一句描述。
61+
62+
例如:
63+
64+
```yml
65+
Help-Key: '@commands.bindings.auction'
66+
```
67+
68+
这会影响:
69+
70+
- `/ms help`
71+
- `/auction help`
72+
- `/ms auction help`
73+
74+
## `Help`
75+
76+
这是多行帮助文本,会在模块帮助页里优先显示。
77+
78+
支持两种写法。
79+
80+
### 写法 1:列表
81+
82+
```yml
83+
Help:
84+
- '&7拍卖模块支持英式拍卖与荷兰式拍卖。'
85+
- '&7打开大厅: &f{command} open'
86+
- '&7上架物品: &f{command} upload <english|dutch> <起拍价> [一口价|结束价] [时长]'
87+
```
88+
89+
### 写法 2:多行字符串
90+
91+
```yml
92+
Help: |-
93+
&7交易记录用于查看成交、退款和统计信息。
94+
&7打开记录页: &f{command} open [关键字]
95+
&7查看详情: &f{command} detail <记录ID>
96+
```
97+
98+
当前实现两种都支持。
99+
100+
## `Hint-Keys`
101+
102+
`Hint-Keys` 用于某个子动作的提示文案。
103+
104+
例如:
105+
106+
```yml
107+
Hint-Keys:
108+
open: '@commands.bindings.auction'
109+
bid: '@commands.hints.auction-bid'
110+
upload-english: '@commands.hints.auction-upload-english'
111+
```
112+
113+
模块代码在需要时会按 key 读取:
114+
115+
- `open`
116+
- `bid`
117+
- `upload`
118+
- `request`
119+
- `money`
120+
- `exp`
121+
- `amount`
122+
123+
具体支持哪些 key,取决于模块本身。
124+
125+
## 可用占位符
126+
127+
在 `Help` 文本里当前可以稳定使用:
128+
129+
| 占位符 | 说明 |
130+
| --- | --- |
131+
| `{command}` | 当前实际使用的命令前缀 |
132+
| `{binding}` | 当前绑定命令,不含 `/` |
133+
| `{shop-id}` | 当前商店 id |
134+
| `{shop}` | 当前商店 id |
135+
136+
这意味着:
137+
138+
- `/auction help` 会显示 `/auction ...`
139+
- `/ah help` 会显示 `/ah ...`
140+
- `/cart help` 会显示 `/cart ...`
141+
142+
## 一个完整示例
143+
144+
### `Auction/shops/default.yml`
145+
146+
```yml
147+
Bindings:
148+
Commands:
149+
Bindings:
150+
- 'auction'
151+
- 'ah'
152+
Register: true
153+
Show-In-Help: true
154+
Priority: 100
155+
Help-Key: '@commands.bindings.auction'
156+
Hint-Keys:
157+
open: '@commands.bindings.auction'
158+
bid: '@commands.hints.auction-bid'
159+
upload-english: '@commands.hints.auction-upload-english'
160+
upload-dutch: '@commands.hints.auction-upload-dutch'
161+
Help:
162+
- '&7拍卖模块支持英式拍卖与荷兰式拍卖。'
163+
- '&7打开大厅: &f{command} open'
164+
- '&7上架物品: &f{command} upload <english|dutch> <起拍价> [一口价|结束价] [时长]'
165+
- '&7出价: &f{command} bid <id> [价格]'
166+
- '&7管理自己的拍卖: &f{command} manage'
167+
```
168+
169+
### `Cart/settings.yml`
170+
171+
```yml
172+
Bindings:
173+
Commands:
174+
Bindings:
175+
- 'cart'
176+
Register: true
177+
Show-In-Help: true
178+
Priority: 40
179+
Help-Key: '@commands.bindings.cart'
180+
Hint-Keys:
181+
open: '@commands.bindings.cart'
182+
amount: '@commands.hints.cart-amount'
183+
Help:
184+
- '&7购物车会汇总可结算的条目。'
185+
- '&7打开购物车: &f{command} open'
186+
- '&7打开结算预览: &f{command} checkout [valid_only]'
187+
- '&7确认结算: &f{command} checkout confirm [valid_only]'
188+
- '&7调整数量: &f{command} amount <槽位> <数量>'
189+
```
190+
191+
## 当前表现
192+
193+
现在默认模块的帮助行为是:
194+
195+
- 先输出 `Help` 多行说明
196+
- 再输出固定命令列表
197+
198+
如果没有 `Help`:
199+
200+
- 就只显示固定命令列表
201+
202+
## 重载与生效
203+
204+
`Help`、`Help-Key`、`Hint-Keys` 都属于配置内容。
205+
206+
当前行为:
207+
208+
- `/matrixshopadmin reload` 后即可更新
209+
- 不需要重启服务器
210+
211+
唯一例外仍然是:
212+
213+
- 独立命令关键字本身
214+
- `Register`
215+
216+
这两类改动仍建议重启后验证。

sidebars.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ const sidebars: SidebarsConfig = {
7272
],
7373
},
7474
'matrixshop/bindings-and-ui',
75+
'matrixshop/bindings-help-and-hints',
7576
'matrixshop/faq',
7677
],
7778
},

0 commit comments

Comments
 (0)