批量命令:一个能按预期执行的脚本引擎
对于大多数使用场景来说,Skript 过于复杂,因此我开发了这款插件,以便能够快速地从一个文件中执行一系列命令。
例如,你正在设置 Chunky。通常你需要依次输入:
/chunky world world、/chunky radius 1500、/chunky shape circle 以及 /chunky start。
但是,如果你要在多个服务器上执行此操作,并且懒得手动逐一输入该怎么办?这正是我想要解决的问题:重复的繁琐劳动。
我们现在可以在 /plugins/BatchCommands/batches 文件夹中创建一个名为 chunky.batch 的文件。
其内容如下所示:
chunky world world
chunky radius 1500
chunky shape circle
chunky start
现在,你只需要输入 /filebatch chunky.batch 即可(完全支持实时 Tab 补全)。
这几乎涵盖了人们一生中可能用到的所有功能。但如果我们想要更多呢?比如,我想在开始 Chunky 的世界生成之前等待一秒(20 刻)?
脚本将使用我们的装饰器 !sleep ticks:
chunky world world
chunky radius 1500
chunky shape circle
!sleep 1
chunky start
现在,该插件将执行前三条命令,然后等待 20 刻(一秒),再执行后续命令。
需要语法方面的帮助吗?
别担心,我们拥有一个高度可配置的全面检查系统。
配置选项将在下方提供。
config.yml
# -------------------------------------------------- #
# BatchCommands Configuration #
# -------------------------------------------------- #
# 启用此项以在控制台中查看更详细的日志。
# 这对于服务器管理员进行调试非常有用。
debug-mode: false
# -------------------------------------------------- #
# Execution Settings #
# -------------------------------------------------- #
# 警告:修改这些设置可能会带来 #
# 潜在的安全风险。在更改之前请理解 #
# 其后果。 #
# -------------------------------------------------- #
execution:
# 默认执行者:CONSOLE(控制台)或 SENDER(发送者)
# 决定默认情况下由谁运行批处理文件中的命令。
# - CONSOLE:(默认,最安全)所有命令均由服务器控制台运行。
# - SENDER:(有风险)命令由发起 /filebatch 命令的玩家运行。
# 如果非管理员拥有运行此命令的权限,这将很危险,
# 因为他们可以使用自己的(可能有局限的)权限执行命令。
default-executor: CONSOLE
# 出错时停止:true 或 false
# 如果为 true,任何命令失败时批处理执行都会立即中止。
# 如果为 false(有风险),即使命令失败,批处理仍会继续,这可能导致
# 意外行为或操作不完整。
stop-on-error: true
# 允许 OP 命令:true 或 false
# 如果为 false(默认,最安全),则禁止通过此插件运行 /op、/deop 等命令,
# 无论执行者是谁。
# 如果为 true(极高风险),则允许这些命令。如果 'default-executor' 为 SENDER,
# 玩家可以编写包含 "op <their_name>" 的批处理文件并尝试获取管理员权限。
allow-op-commands: false
# 命令黑名单:永远不能运行的命令列表。
# 这是防止灾难性命令的最终保障。
# 命令列表中不应包含斜杠。例如:"stop" 而不是 "/stop"。
command-blacklist:
- "stop"
- "reload"
- "rl"
- "restart"
- "plugman"
lint-engine:
# 检查引擎模式
# BEFORE - 在执行前进行检查
# AS_WE_GO - 边执行边检查(检查不够彻底,但启动更快)
engine-mode: BEFORE
checking-order:
- "EMPTY_FILE" # 检查文件是否包含任何可执行行。
- "ILLEGAL_CMD" # 检查是否存在黑名单上的命令或被禁用的 OP 命令。
- "UNKNOWN_DECORATOR" # 检查是否存在不存在的装饰器(例如 !fly)。
- "SYNTAX_ERRS" # 检查是否存在格式错误的装饰器(例如没有数字的 !sleep)。
- "RECURSIVE_EXECUTION" # 检查文件是否试图调用自身。
max-checking-time: 1000 # 检查引擎的最大检查时间,如果超过此值,我们将尊重下一个设置
# 可能的选项:
# STOP - 停止执行
# TRY_AGAIN - 重试,最大重试次数可以更改
# STOP_AND_WARN - 通知控制台此错误
# FORCE_START - 强制启动脚本——这将导致漏洞利用!!!
if-exceed-max-time: STOP_AND_WARN
max-retry-attempts: 5
scripting:
# 这是表示批处理文件中注释行的字符。
# 任何以该字符开头的行在执行时将被忽略。
# 默认为 "#"。
comment-char: "#"
# 装饰器字符
# 此字符用于识别批处理文件中的特殊装饰器。
# 例如,"!sleep 5" 使用 "!" 作为装饰器字符。
# 默认为 "!"。
decorator-char: "!"
timing:
# 计时模式:
# WORLD - 使用世界的刻数(同步,受 TPS 影响)
# INTERNAL - 使用内部定时器来安排睡眠任务(尚未实现)
# CLOCK - 使用服务器时钟来安排睡眠任务(尚未实现)
ticking-mode: WORLD
Batch commands: A scripting engine that does what it intends to do
Skript is a little too complex for most usage cases, so I made this plugin to be able to execute a series of commands from a file quickly.
For instance, you are setting up chunky. Normally you'd do:
/chunky world world /chunky radius 1500 /chunky shape circle and /chunky start
But what if you are doing this across multiple servers and are lazy enough to not want to do so? Here's what I aim to solve: repetative mannual labor.
We can now create a file within the /plugins/BatchCommands/batches folder named chunky.batch
Inside, it would look like this:
chunky world world
chunky radius 1500
chunky shape circle
chunky start
Now all you have to do is type /filebatch chunky.batch (Live tab completion fully supported).
Now, this is almost all the features anyone would possibly need in their lifetime. But what if we want more? What if I want to wait one second (twenty ticks) before starting the chunky worldgen?
The script will use our decorator !sleep ticks
chunky world world
chunky radius 1500
chunky shape circle
!sleep 1
chunky start
Now this plugin will execute the first three commands and then wait 20 ticks (one second) to perform the subsequent command.
Need help with the syntax?
Don't worry, we have an extensive linting system that is highly configurable.
Configuration options will be provided below
config.yml
# -------------------------------------------------- #
# BatchCommands Configuration #
# -------------------------------------------------- #
# Enable this to see more detailed logs in the console.
# This is useful for server administrators for debugging purposes.
debug-mode: false
# -------------------------------------------------- #
# Execution Settings #
# -------------------------------------------------- #
# WARNING: Modifying these settings can create #
# potential security risks. Understand the #
# implications before changing them. #
# -------------------------------------------------- #
execution:
# Default Executor: CONSOLE or SENDER
# Determines who runs the commands inside the batch file by default.
# - CONSOLE: (Default, Safest) All commands are run by the server console.
# - SENDER: (RISKY) Commands are run by the player who initiated the /filebatch command.
# This is dangerous if non-admins have the permission to run this command,
# as they could execute commands with their own (potentially limited) permissions.
default-executor: CONSOLE
# Stop on Error: true or false
# If true, the batch execution will halt immediately if any command fails.
# If false (RISKY), the batch will continue even if a command fails, which can lead to
# unexpected behavior or incomplete actions.
stop-on-error: true
# Allow OP Commands: true or false
# If false (Default, Safest), commands like /op, /deop, etc., are blocked from running
# through this plugin, regardless of the executor.
# If true (EXTREMELY RISKY), these commands are allowed. If 'default-executor' is SENDER,
# a player could write a batch file with "op <their_name>" and try to gain operator status.
allow-op-commands: false
# Command Blacklist: A list of commands that can NEVER be run.
# This is a final safeguard against catastrophic commands.
# Commands should be listed without the slash. e.g., "stop" not "/stop".
command-blacklist:
- "stop"
- "reload"
- "rl"
- "restart"
- "plugman"
lint-engine:
# Lint engine mode
# BEFORE - check before executing the script
# AS_WE_GO - check as we go (less thorough, but faster startup)
engine-mode: BEFORE
checking-order:
- "EMPTY_FILE" # Checks if the file contains any executable lines.
- "ILLEGAL_CMD" # Checks for blacklisted or disabled OP commands.
- "UNKNOWN_DECORATOR" # Checks for decorators that don't exist (e.g., !fly).
- "SYNTAX_ERRS" # Checks for malformed decorators (e.g., !sleep without a number).
- "RECURSIVE_EXECUTION" # Checks if the file tries to call itself.
max-checking-time: 1000 #Max checking time for lint engine, if it exceeds this we will respect the next setting
# Possible options:
# STOP - Stop the execution
# TRY_AGAIN - Retry, max attempts can be changed
# STOP_AND_WARN - Notify console of this error
# FORCE_START - forcably start the script - THIS WILL LEAD TO EXPLOITS!!!
if-exceed-max-time: STOP_AND_WARN
max-retry-attempts: 5
scripting:
# This is the character that denotes a comment line in the batch file.
# Any line starting with this character will be ignored during execution.
# Default is "#".
comment-char: "#"
# Decorator Character
# This character is used to identify special decorators in the batch file.
# For example, "!sleep 5" uses "!" as the decorator character.
# Default is "!".
decorator-char: "!"
timing:
# Ticking modes:
# WORLD - Uses the world's ticks (synchronous, affected by TPS)
# INTERNAL - Uses an internal timer to schedule sleep tasks (Not yet implemented)
# CLOCK - Uses the server's clock to schedule sleep tasks (Not yet implemented)
ticking-mode: WORLD
评论 0
登录后参与评分
还没有评论,来抢沙发吧