条件系统
Attribute 条件文件位于 conditions/*.yml。条件组可用于装备限制、配方限制、技能限制和其他模块的业务判断。默认条件示例中部分可能是 enabled: false,需要根据服务器需求手动开启。
条件组字段
| 字段 | 类型 | 默认值 | 说明 |
|---|---|---|---|
enabled | boolean | true | 是否启用该条件组。 |
source_id | string | — | 条件来源或业务标识。 |
condition_type | string | all_of | 条件组合方式。 |
required_count | integer | 1 | 当 condition_type 为 at_least 或 exactly 时,需要满足的条件数量。 |
invalid_as_failure | boolean | true | 条件配置异常或解析失败时是否视为不通过。 |
conditions | 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 的属性值)。 |
$0、$1、$2... | 正则捕获组(lore_regex 类型中可用)。 |
%source_meta_<key>% | payload meta 中指定 key 的值。 |
%source_attribute_<key>% | payload attributes 中指定属性的值。 |
%source_id% | payload 的 source_id。 |
%player_name% | 玩家名称。 |
%player_level% | 玩家经验等级。 |
如果安装了 PlaceholderAPI,所有 PAPI 占位符也可在条件表达式中使用。
示例:PDC meta 条件
yaml
enabled: true
source_id: forge
condition_type: all_of
invalid_as_failure: true
conditions:
- type: pdc_meta
key: required_level
condition: '%value% <= %player_level%'示例:属性值条件
yaml
enabled: true
source_id: equipment_check
condition_type: all_of
conditions:
- type: pdc_attribute
key: physical_attack
condition: '%value% >= 50'示例:来源匹配条件
yaml
enabled: true
source_id: strengthen
condition_type: all_of
conditions:
- type: source_id
condition: '%source_id% == "strengthen"'示例:Lore 正则条件
yaml
enabled: true
source_id: legacy_weapon
condition_type: any_of
invalid_as_failure: true
conditions:
- 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
conditions:
- 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 | 强化来源,默认无条件直接通过。 |
forge.yml | forge | 锻造来源,检查 required_level <= player_level。 |
emakiitem.yml | emakiitem | 物品来源,检查 condition_expressions 表达式。 |
default_bind.yml | gem_bind | 宝石绑定,检查 bound_player == player_name。默认禁用。 |
default_equipment_level.yml | gem_equipment_level | 装备等级,lore_regex 检查。默认禁用。 |