Skip to content

条件系统

Attribute 条件文件位于 conditions/*.yml。条件组可用于装备限制、配方限制、技能限制和其他模块的业务判断。默认条件示例中部分可能是 enabled: false,需要根据服务器需求手动开启。

条件组字段

字段类型默认值说明
enabledbooleantrue是否启用该条件组。
source_idstring条件来源或业务标识。
condition_typestringall_of条件组合方式。
required_countinteger1condition_typeat_leastexactly 时,需要满足的条件数量。
invalid_as_failurebooleantrue条件配置异常或解析失败时是否视为不通过。
conditionslist[]条件条目列表。

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 条目字段

字段说明
typepdc_meta
key要检查的 meta key。
condition比较表达式,支持占位符和运算符。

lore_regex 条目字段

字段说明
typelore_regex
pattern正则表达式。
require_match是否要求匹配成功(true 表示必须匹配到)。

pdc_attribute 条目字段

字段说明
typepdc_attribute
key属性 ID。
condition比较表达式。

source_id 条目字段

字段说明
typesource_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.ymlstrengthen强化来源,默认无条件直接通过。
forge.ymlforge锻造来源,检查 required_level <= player_level
emakiitem.ymlemakiitem物品来源,检查 condition_expressions 表达式。
default_bind.ymlgem_bind宝石绑定,检查 bound_player == player_name。默认禁用。
default_equipment_level.ymlgem_equipment_level装备等级,lore_regex 检查。默认禁用。