Skip to content

条件判断 ​

条件是机关的门槛,并不会主动执行动作。在触发器中,conditions 里的条件需要全部通过,才开始执行 actions。空列表 conditions: [] 表示没有额外限制。

🔐 只有 30 级且持有钥匙的玩家可以开门 ​

yaml
等级钥匙门:
  enabled: true
  event: block_click
  target: 'point:工作台机关'
  scope: PLAYER
  once: false
  cooldown-ticks: 20
  conditions:
    - type: expression
      expression: 'player.level >= 30'
    - type: item
      item: 遗迹钥匙
      amount: 1
  actions:
    - type: take_item
      item: 遗迹钥匙
      amount: 1
    - type: message
      text: '&a成功使用钥匙!'

等级不够或者没有钥匙,都不会触发动作。item 只检查物品,消耗物品要额外使用 take_item。如果只想做一个等级门,删掉 item 条件和扣除动作即可。

🎯 条件自动检测 ​

例如核心房间没有僵尸时显示通关提示:

yaml
清理守卫:
  enabled: true
  event: condition_watch
  scope: INSTANCE
  once: true
  interval-ticks: 20
  edge: RISING
  conditions:
    - type: entity_count
      target: 'region:核心房间'
      entity: ZOMBIE
      min: 0
      max: 0
  actions:
    - type: message
      text: '&a守卫已清理!'

RISING 是条件由不成立变为成立时触发;WHILE_TRUE 是持续成立时每隔检测周期触发。若房间开始时就没有僵尸,应将阶段或点位状态加入条件,让检测只在战斗阶段生效。

下列每种条件都可以单独加入 conditions,不用同时配置。

玩家与挑战条件 ​

这些条件与触发玩家、当前遗迹或阶段有关。

permission ​

permission 是必须拥有的权限节点。

yaml
conditions:
- type: permission
  permission: example.ruin.use

chance ​

chance 范围 0~1;0 永不通过,1 总通过。

yaml
conditions:
- type: chance
  chance: 0.5

stage ​

flow 为流程 ID,stage 为必须处于的阶段 ID。

yaml
conditions:
- type: stage
  flow: main
  stage: exploration

item ​

item 是遗迹物品库 ID,amount 为最低持有数量。

yaml
conditions:
- type: item
  item: 遗迹钥匙
  amount: 1

player_count ​

min 和 max 是当前遗迹内玩家数量的范围。

yaml
conditions:
- type: player_count
  min: 1
  max: 10

expression ​

expression 使用 RemainsScript 表达式,可以组合 &&、|| 和大小比较。

yaml
conditions:
- type: expression
  expression: player.health > 5 && player.level >= 0

papi ​

placeholder 是左值,value 是右值,均可进行占位符解析;operator 指定比较关系,compare-as: AUTO 自动选择比较类型;ignore-case 用于字符串比较。示例比较当前触发玩家(ACTOR)的等级。需要 PlaceholderAPI。

yaml
conditions:
- type: papi
  placeholder: '%player_level%'
  operator: '>='
  value: '30'
  compare-as: AUTO
  ignore-case: false
  subject: ACTOR

位置与世界条件 ​

target 和 offset 的写法见 动作的位置写法。对于数量统计,min、max 表示允许的数量范围;对于光照、时间等条件,则表示对应数值的范围。

block ​

material 是目标方块材质,data 为旧版方块数据。

yaml
conditions:
- type: block
  target: block:5,1,6
  material: WORKBENCH
  data: 0

redstone ​

min、max 为红石信号范围(0~15)。

yaml
conditions:
- type: redstone
  target: block:7,1,3
  min: 1
  max: 15

distance ​

检查玩家距离目标位置是否在 min~max 格之间。

yaml
conditions:
- type: distance
  target: point:工作台机关
  offset:
  - 0
  - 0
  - 0
  min: 0
  max: 6

player_nearby ​

统计目标周围 radius 格范围内的玩家,min、max 为人数限制。

yaml
conditions:
- type: player_nearby
  target: block:5,1,6
  radius: 8
  min: 1

entity_count ​

entity 为 Bukkit 实体类型;使用区域目标可统计整个区域内该类型的实体。

yaml
conditions:
- type: entity_count
  target: region:核心房间
  entity: ZOMBIE
  min: 0
  max: 0

mythicmob_count ​

id 为 MM 怪物内部 ID;不写 id/mob 时统计所有 MythicMobs 活跃怪物。

yaml
conditions:
- type: mythicmob_count
  target: region:核心房间
  id: ExampleBoss
  min: 0
  max: 0

light ​

min、max 为光照值范围(0~15)。

yaml
conditions:
- type: light
  target: block:5,1,6
  min: 0
  max: 15

biome ​

biome 为目标位置所在群系的 Bukkit 名称。

yaml
conditions:
- type: biome
  target: block:5,1,6
  biome: PLAINS

time ​

min、max 为世界日周期时间(0~23999);23000~1000 表示跨午夜区间。

yaml
conditions:
- type: time
  target: block:5,1,6
  min: 0
  max: 23999

point_state ​

point 为点位 ID,state 为要求的点位状态,配合 set_point_state 动作使用。

yaml
conditions:
- type: point_state
  point: 工作台机关
  state: ACTIVE

返回功能教程