Skip to content

ConditionalCommands

仅在满足条件时执行命令。

ConditionalCommands 旨在用于当插件具有自动命令时,这些命令仅在满足特定条件时才执行。它能够执行多个命令,并且可以为每个命令自定义延迟。

此功能已被 konsolas 的 ConditionalCommands 项目 修改,并已 内置于 Matrix 中。
原项目地址: https://github.com/konsolas/ConditionalCommands

使用方法

/coc <player> unless <condition> do <command>
/coc <player> if <condition> do <command>
/coc help

条件

条件的语法:

<expression>::=<term>{<or><term>}
<term>::=<factor>{<and><factor>}
<factor>::=<comparison>|<not><factor>|(<expression>)
<comparison>::=<constant><comparator><constant>
<constant>::=浮点数或整数
<and>::='&'
<or>::='|'
<not>::='!'
<comparator>::='>'|'='|'<'

如上所述,仅支持数字比较,且占位符只能包含数字。如果在一组中有多个比较运算符,例如 3>=<2,只有第一个运算符会被使用。比较中不能包含空格。可以通过 !(value=value) 检查不等式。

示例:

/coc RERERE unless -ping->200 do kick RERERE
/coc RERERE if (-ping-<300&-ping->100)&-tps->15.0 do msg RERERE Your ping is between 300 and 100, and the TPS is greater than 15.

配置文件中的示例

yaml
## Jesus
# 检查防止玩家在液体中移动过快或在液体上行走。
jesus:
  # 是否启用此检查?
  enable: true

  # 需要多少违规点数才能取消非法移动 (-1 = 永不取消)
  cancel_vl: 15

  # 违规阈值
  # number_of_violations: '<command>'
  commands:
    10: 'coc %player% if -ping-<120&-tps->19.5 do matrix notify %player% tried to move illegally in liquid (Jesus)'
    25: 'coc %player% if -ping-<50&-tps->19.5&-time_online->10000 do matrix kick %player% Jesus/WaterSpeed/WaterFly Hacks'
    40: 'matrix kick %player% Jesus/WaterSpeed/WaterFly Hacks'

占位符

占位符由 '-' 分隔。由于它们通过替换应用,因此如果输入错误,可能会在解析时检测到错误。

  • ping - 被测试玩家的延迟。
  • tps - 服务器过去 2 秒的 TPS 平均值。
  • time_online - 玩家在线时间(毫秒)。
  • uptime - 服务器运行时间(以 tick 为单位)。
  • player_count - 服务器上的玩家数量。
  • perm:<permission> - 如果玩家拥有此权限则为 1.0,否则为 0.0。例如 -perm:essentials.home-
  • vl:<check> - 给定检查(内部名称)的 Matrix 违规等级。例如 -vl:speed-
  • chance:<percentage>% - 按百分比的概率为 1.0。例如 -chance:34.5%-

多命令 / 延迟命令

在语句的 'do' 子句中,可以一次执行多个命令,并且可以为选定的命令设置延迟。命令分隔符为 /<delay>/,其中 // 之间的整数表示命令应在多少 tick 后执行。以下是一些示例:

/coc konsolas if -vl:killaura->0 do /1200/ ban konsolas 1 minute delayed ban for killaura
/coc konsolas if -perm:some.permission-=1 do /0/ broadcast konsolas has some.permission! /0/ broadcast second broadcast! /20/ broadcast 1 second later!

开发者模式

Matrix 内置的 ConditionalCommands 系统已移除开发者模式。

Made with ❤️ by RE