Repository navigation
Commands
HimDSL 只提供一个命令 /himdsl,它有三个子命令:
-
compile—— 只检查语法,不执行。 -
run—— 解析并执行脚本。 -
debug—— 打开或关闭调试日志。
HimDSL exposes a single command /himdsl with three subcommands:
-
compile— syntax check only, no execution. -
run— parse and execute the script. -
debug— toggle verbose logging.
本章逐个讲解。所有路径都是相对于 plugins/HimDSL/ 的相对路径。
This chapter covers each in turn. All paths are relative to plugins/HimDSL/.
compile 只做一件事:把你写的脚本交给语法解析器,看能不能读懂。它不执行任何逻辑,也不会修改服务器状态。
compile does one thing: hand your script to the parser and see if it can be understood. It runs no logic and changes no server state.
/himdsl compile hello.himdsl
/himdsl compile scripts/farm_timer.himdsl
成功时返回 §a编译通过!。失败时返回 §c编译错误: ...,并带出错位置。养成习惯:先 compile,再 run。这会帮你把拼写错误、括号不匹配、分号遗漏之类的问题在执行前挡掉。
On success it returns §a编译通过!. On failure it returns §c编译错误: ... with the error location. Make it a habit: compile first, then run. This catches typos, mismatched braces, and missing semicolons before execution.
run 会解析并执行脚本。基本用法:
run parses and executes the script. Basic usage:
/himdsl run hello.himdsl
你也可以给 run 传参数,这些参数会按顺序传给脚本里的 main 函数:
You can also pass arguments to run; they are forwarded to main in order:
/himdsl run greet.himdsl Steve
对应的脚本必须接收一个参数:
The script must accept one parameter:
int main(string who) {
runcmd("CONSOLE", "say 欢迎 " + who + "!");
}
多个参数依次排列:/himdsl run score.himdsl Steve 100 对应 int main(string name, int score)。参数个数必须与 main 声明的形参个数一致,否则报错。
Multiple arguments line up in order: /himdsl run score.himdsl Steve 100 matches int main(string name, int score). The argument count must match the number of main parameters, or an error is thrown.
从命令传进来的参数一律是字符串。即使你写 100,main 收到的也是字符串 "100"。如果你需要当作数字使用,必须自己转换:
Arguments from the command line always arrive as strings. Even if you type 100, main receives the string "100". If you need a number, convert it yourself:
int main(string countText) {
int count = toInt(countText);
runcmd("CONSOLE", "say 循环 " + count + " 次");
}
内置函数 toInt 会把字符串转成整数,类似的还有 toDouble、toLong、toBool。这一条会在后面的内置函数章节详细展开。
The built-in toInt converts a string to an integer; related helpers include toDouble, toLong, and toBool. This is covered in detail in the built-ins chapter.
debug 有四个取值:
-
on/off—— 打开或关闭详细日志。 -
codeon/codeoff—— 打开或关闭"运行前打印脚本内容"。
debug takes four values:
-
on/off— toggle verbose logging. -
codeon/codeoff— toggle "print script content before each run".
/himdsl debug on
/himdsl debug codeon
打开 codeon 后,每次执行 run,控制台都会先把脚本原文完整打印一遍,再开始执行。这在脚本行为与预期不符时特别有用——你能立刻对照日志中的执行流程和脚本源码。
With codeon, every run prints the full script text to the console before executing. This is especially helpful when behavior differs from expectation — you can cross-reference the log against the source immediately.
这两个开关不会持久化:服务器重启后会自动回到关闭状态。想要打开就重新执行一次命令。
Both toggles are not persisted: they reset to off after a server restart. Re-run the command to enable them again.
compile 和 run 的第一个参数是路径。它必须是相对于 plugins/HimDSL/ 的相对路径:
The first argument of compile and run is a path. It must be relative to plugins/HimDSL/:
/himdsl run hello.himdsl ✓
/himdsl run scripts/farm.himdsl ✓
/himdsl run /etc/passwd ✗ 绝对路径会被拒绝
/himdsl run ../../config.yml ✗ 试图逃出插件目录
插件不会执行插件目录以外的文件。这是一个安全边界,即使你手滑写错路径,也不会误伤系统文件。
The plugin will not execute files outside its directory. This is a safety boundary: even a slip of the finger cannot touch system files.
权限由插件的 plugin.yml 声明。三个节点默认授予 OP:
himdsl.use —— 允许 /himdsl compile
himdsl.run —— 允许 /himdsl run
himdsl.debug —— 允许 /himdsl debug ...
没有对应权限的玩家无法执行相应子命令。需要精细控制时,通过权限管理插件(LuckPerms 等)按需授予。
Permissions are declared in the plugin's plugin.yml. Three nodes default to OP:
himdsl.use — allows /himdsl compile
himdsl.run — allows /himdsl run
himdsl.debug — allows /himdsl debug ...
Players without the matching permission cannot run that subcommand. For finer control, grant them via a permissions plugin (LuckPerms, etc.).
-
compile只检查语法,run执行脚本。 -
run可以传参数,参数一律是字符串。 -
debug on打开详细日志,debug codeon打印脚本原文。 -
路径必须是插件目录内的相对路径。
-
默认没有权限限制,生产环境自行加固。
-
compilechecks syntax;runexecutes the script. -
runaccepts arguments; all arguments are strings. -
debug onenables verbose logs;debug codeonprints the script text. -
Paths must be relative and inside the plugin directory.
-
No default permission; harden it in production.
下一章 [自动执行脚本 / Auto-Scripts] 介绍两个特殊脚本:它们在服务器启动完成、以及关闭时自动执行,无需任何命令。
The next chapter [自动执行脚本 / Auto-Scripts] introduces two special scripts that run automatically at server startup and shutdown — no command needed.
- 首页 / Home
- 安装与快速开始 / Installation & Quick Start
- 第一个脚本 / Your First Script
- 命令速查 / Command Reference
- 自动执行脚本 / Auto-run Scripts
- 定义函数 / Defining Functions
- 函数重载 / Function Overloading
- Lambda 表达式 / Lambda Expressions
- 函数式接口 / Functional Interfaces
- 选择器总览 / Selectors Overview
- 选择器过滤器 / Selector Filters
- EntityRef 引用 / EntityRef
- 占位符参考 / Placeholders Reference
- PlaceholderAPI 桥接 / PAPI Bridge
- 创建 GUI / Creating a GUI
- GUISlot 槽位 / GUISlot
- 点击回调 / Click Callbacks
- onClose 回调 / onClose Callback
- GUI 刷新 / GUI Refresh
- 数学函数 / Math Built-ins
- 高精度计算 / BigDecimal Built-ins
- 字符串函数 / String Built-ins
- 集合函数 / Collection Built-ins
- 文件 I/O / File I/O
- 命令与 sleep / Commands & sleep