简体中文
条件系统
条件文件要写清的内容如下: 条件组有哪些字段, 能放哪几种条件条目, 条件表达式里可以用哪些变量
条件文件放在 conditions/*.yml. 你可以把条件组用在装备限制, 配方限制, 技能限制和其他模块的判断上. 注意, 默认条件示例里有一部分写着 enabled: false, 需要你按服务器需求手动打开
条件组字段
| 字段 | 类型 | 默认值 | 说明 |
|---|---|---|---|
enabled | boolean | true | 要不要启用这个条件组 |
source_id | string | — | 条件来源或业务标识 |
condition.type | string | all_of | 条件的组合方式 |
condition.required_count | integer | 1 | 当 condition.type 为 at_least 或 exactly 时, 需要满足几条条件 |
condition.invalid_as_failure | boolean | true | 条件配置异常或解析失败时, 要不要当作不通过 |
condition.entries | list | [] | 条件条目列表 |
condition.type 完整枚举
| 值 | 说明 |
|---|---|
all_of | 全部条件都满足才通过 |
any_of | 任意一个条件满足就通过 |
at_least | 至少满足 required_count 个条件 |
exactly | 恰好满足 required_count 个条件 |
none_of | 全部条件都不满足才通过 |
条件条目类型
| 类型 | 说明 |
|---|---|
pdc_meta | 检查 payload 中 meta 字段的值 |
lore_regex | 用正则匹配物品 Lore |
pdc_attribute | 检查 payload 中某个属性的数值 |
source_id | 检查 payload 的 source_id 是否匹配 |
pdc_meta 条目字段
| 字段 | 说明 |
|---|---|
type | pdc_meta |
key | 要检查的 meta key |
condition | 比较表达式, 支持占位符和运算符 |
lore_regex 条目字段
| 字段 | 说明 |
|---|---|
type | lore_regex |
pattern | 正则表达式 |
require_match | 要不要要求匹配成功 (true 表示必须匹配到) |
pdc_attribute 条目字段
| 字段 | 说明 |
|---|---|
type | pdc_attribute |
key | 属性 ID |
condition | 比较表达式 |
source_id 条目字段
| 字段 | 说明 |
|---|---|
type | source_id |
condition | 比较表达式, 检查 payload 的 source_id |
条件表达式内置变量
你在 condition 字段里可以用这些变量:
| 变量 | 说明 |
|---|---|
%value% | 当前字段值 (pdc_meta 的 key 对应值, 或 pdc_attribute 的属性值).lore_regex 分支例外: 那里传入的是命中的整行 Lore, 不是捕获组, 因此 %value% <= %player_level% 这类数值比较不成立, 请改用 $1 |
$0, $1, $2... | 正则捕获组 (lore_regex 类型中可用). $0 为整个匹配, $1 起为各捕获组. lore_regex 下取数值请用这些变量 |
%source_meta_<key>% | payload meta 中指定 key 的值 |
%source_attribute_<key>% | payload attributes 中指定属性的值 |
%source_id% | payload 的 source_id |
%player_name% | 玩家名称 |
%player_level% | 玩家经验等级 |
NOTE
如果安装了 PlaceholderAPI, 所有 PAPI 占位符也可在条件表达式中使用
示例: PDC meta 条件
yaml
enabled: true
source_id: forge
condition:
type: all_of
invalid_as_failure: true
entries:
- type: pdc_meta
key: required_level
condition: '%value% <= %player_level%'示例: 属性值条件
yaml
enabled: true
source_id: equipment_check
condition:
type: all_of
entries:
- type: pdc_attribute
key: physical_attack
condition: '%value% >= 50'示例: 来源匹配条件
yaml
enabled: true
source_id: strengthen
condition:
type: all_of
entries:
- type: source_id
condition: '%source_id% == "strengthen"'示例: Lore 正则条件
yaml
enabled: true
source_id: legacy_weapon
condition:
type: any_of
invalid_as_failure: true
entries:
- type: lore_regex
pattern: '.*武器等级: (\d+).*'
require_match: true
condition: '$1 >= 20'示例: 至少满足 N 个条件
yaml
enabled: true
source_id: multi_check
condition:
type: at_least
required_count: 2
entries:
- type: pdc_meta
key: enchant_level
condition: '%value% >= 3'
- type: pdc_meta
key: quality
condition: '%value% == "epic"'
- type: pdc_attribute
key: physical_attack
condition: '%value% >= 100'内置条件文件
默认生成的条件文件:
| 文件 | source_id | 说明 |
|---|---|---|
strengthen.yml | strengthen | 强化来源, entries 为空, 无条件通过 |
forge.yml | forge | 锻造来源, 检查 required_level <= %player_level% |
emakiitem.yml | emakiitem | 物品来源, 把 condition_expressions 的值当作表达式执行; require_match: false 表示该 key 不存在时跳过而不是失败 |
default_bind.yml | gem_bind | 绑定检查 bound_player == %player_name%. 默认禁用 |
default_equipment_level.yml | gem_equipment_level | 用 lore_regex 匹配装备等级需求并与 %player_level% 比较. 默认禁用 |
改完条件文件后先执行 /ea lint, 这样在重载前就能发现 schema 问题 (缺少 source_id, 不支持的 checks 字段, 非法条件类型, 缺少 key / pattern, 无效正则等)