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 - 服务器运行时间(刻)。
  • player_count - 服务器上的玩家数量。
  • perm:<permission> - 如果玩家有该权限则为 1.0,否则为 0.0。例如 -perm:essentials.home-
  • vl:<check> - 给定检查(内部名称)的 Matrix 违规级别。例如 -vl:speed-
  • chance:<percentage>% - 将在 percentage% 的时间内为 1.0。例如 -chance:34.5%-

多命令 / 延迟命令

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

/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 内置的条件命令系统中,开发者模式已被移除。

Made with ❤️ by RE