|
| 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 | +这两类改动仍建议重启后验证。 |
0 commit comments