HimDSL
HimDSL 是适用于 Minecraft Java 服务器的脚本语言插件。它允许服务器管理员和地图制作者使用简洁、类 Java 的语法编写事件监听器、定时任务、GUI 菜单、数值逻辑和状态机,而 无需编写或编译 Java 插件。
脚本使用 .himdsl 扩展名,存放在 plugins/HimDSL/ 目录下,可通过单个命令执行,或在服务器启动和关闭时自动运行。
为什么选择 HimDSL?
大多数 Minecraft 服务器经常需要一些小型逻辑功能:欢迎新玩家、自动保存数据、构建商店菜单、运行倒计时、检查生命值等。为每一项功能都编写一个 Java 插件显然大材小用。现有的脚本选项要么限制过多,要么过于依赖特定功能,或者与你熟悉的语言相去甚远。
HimDSL 恰好处于中间地带。它提供了 真正的变量、类型化的函数、结构体(structs)、枚举(enums)、Lambda 表达式以及函数重载 —— 这些正是 Java 程序员所熟知的特性 —— 同时内置了 Minecraft 感知工具:
-
选择器(@p、@a、@r、@s、@e)作为一等表达式。
-
事件注解,用于挂钩 Bukkit 事件。
-
调度注解,用于处理重复或延迟任务。
-
GUI 原语,支持点击和关闭回调。
-
PlaceholderAPI 集成,无需任何 Java 代码。
-
直接 Java 互操作:使用 new <完全限定名>(...) 从其他插件创建对象,调用静态方法,读取静态字段 —— 无需包装器,无需注册。
特性
语言
int / double / bool / string / var,支持运行时类型检查
- 完整的控制流:
if / else、for、while、do-while、break、continue、return
- 支持重载、Lambda 表达式和闭包的强类型函数
- 结构体(Structs),包含字段和成员方法(实例方法与静态方法)
- 用户自定义枚举,可直接与字符串进行比较
- 数组、
vector(列表)、set、map、stack、queue
- 通过
toJson / fromJson 进行 JSON 序列化
Minecraft 集成
- 带有过滤器的实体选择器(
limit、distance、level、name、world、gamemode、type)
EntityRef,支持实时字段(p.name、p.health、p.x)和反射方法
- 占位符(
$player$、$world$、$server$、$boss$),用于软依赖功能
@EventHandler 用于 Bukkit 事件,@BukkitRunnable 用于定时任务
runcmd(executor, command) 用于发送命令(玩家或控制台)
- GUI 系统:创建菜单、分配图标、注册点击和关闭回调
内置函数
- 数学运算:
abs、max、min、sqrt、pow、sin、rand 等
- BigDecimal:
bigAdd、bigSub、bigMul、bigDiv、bigDivExact,用于高精度货币计算
- 文件 I/O:
fopen、fread、fwrite、fclose、freadlines、fwritelines、fexists、fdelete
- PlaceholderAPI 桥接:
papi、papiSet、papiRegister、papiUnregister、papiHas
可靠性
- 解析错误会指出具体的行号和列号。
- 运行时错误会记录包含堆栈跟踪的日志,而不会导致服务器崩溃。
- 可选依赖项(PlaceholderAPI、HimDungeons、WorldEdit)具备优雅降级机制——即使缺少这些插件,脚本仍能正常加载。
示例:欢迎新玩家加入
plugins/HimDSL/onServerLoad.himdsl:
@EventHandler
void onJoin(event(PlayerJoinEvent)) {
player p = @s;
runcmd("CONSOLE", "say Welcome " + p.name + " to the server!");
runcmd(p.name, "title @s title {\"text\":\"Welcome\"}");
}
int main() {
start("onJoin");
}
示例:定时自动保存
@BukkitRunnable
void autosave() sche = 300s {
var lines = vector();
lines.add("saved at tps=" + $server(tps)$);
fwritelines("last_save.txt", lines);
}
int main() {
start("autosave");
}
示例:简易商店 GUI
int main() {
var gui = new GUI(3, "§6Shop");
var diamond = new GUISlot(Material.DIAMOND);
diamond.name = "§bDiamond";
diamond.lore = {"§7Price: §e100", "§aLeft-click to buy"};
diamond.onLeftClick = () -> {
player p = @s;
runcmd("CONSOLE", "eco take " + p.name + " 100");
runcmd("CONSOLE", "give " + p.name + " diamond 1");
runcmd(p.name, "msg §aPurchased");
gui.close(p);
};
gui[1][4] = diamond;
gui.updateAll();
gui.open(@p);
}
命令与权限
| 命令 |
描述 |
权限 |
/himdsl compile <path> |
仅进行语法检查 |
himdsl.use |
/himdsl run <path> [args] |
执行脚本 |
himdsl.run |
/himdsl debug on\|off |
切换详细日志输出 |
himdsl.debug |
/himdsl debug codeon\|codeoff |
在每次运行前打印脚本内容 |
himdsl.debug |
所有路径均相对于 plugins/HimDSL/ 目录。上述三个权限默认授予 OP(管理员)。
要求
- 服务器: Bukkit / Spigot / Paper 1.21+(推荐使用 Paper 1.21+)
- Java: 25 或更高版本(最新版本支持 Java 17+)
- 可选依赖:
- PlaceholderAPI — 启用
papi(...) 系列函数
- HimDungeons — 启用
$boss(...)$ 及地牢相关占位符
- WorldEdit — 启用部分世界相关占位符
自动运行脚本
将以下文件放入 plugins/HimDSL/ 目录中即可自动运行:
onServerLoad.himdsl — 在服务器完成加载后执行
onServerShutdown.himdsl — 在插件卸载或服务器关闭时执行
文档
完整文档请参阅 项目 Wiki:
- 快速入门、语言基础、控制流
- 函数、Lambda 表达式、函数式接口
- 数据结构、自定义类型、Java 互操作
- Minecraft 集成、事件与调度、GUI 系统
- 内置函数参考、高级主题、常见陷阱
- 示例脚本(递归、循环、商店 GUI、状态机、小游戏)
面向 Java 开发者
HimDSL 通过 Bukkit 的 ServicesManager 暴露了 HimDSLAPI,以便其他插件能够编译、运行和生成脚本:
HimDSLAPI api = Bukkit.getServicesManager().load(HimDSLAPI.class);
if (api != null) {
api.run(new File(himdslFolder, "script.himdsl"));
}
在 plugin.yml 中添加 softdepend: [HimDSL]。
你可以在以下地址查看完整文档:
许可证
请参阅 LICENSE 文件。
问题与反馈
欢迎在 Issue Tracker 上提交 Bug 报告和功能请求。
HimDSL
HimDSL is a scripting language plugin for Minecraft Java servers. It lets server administrators and map makers write event listeners, scheduled tasks, GUI menus, numeric logic, and state machines using a concise, Java-like syntax — without writing or compiling a Java plugin.
Scripts use the .himdsl extension, live in plugins/HimDSL/, and run through a single command or automatically on server startup and shutdown.
Why HimDSL?
Most Minecraft servers need small pieces of logic all the time: welcome new players, autosave data, build a shop menu, run a countdown, check health. Writing a Java plugin for each of these is overkill. Existing scripting options are either too limited, too tied to a specific feature, or too far from a language you already know.
HimDSL sits in the middle. It gives you real variables, typed functions, structs, enums, lambdas, and function overloading — pieces Java programmers already know — plus Minecraft-aware tools built into the language itself:
- Selectors (
@p, @a, @r, @s, @e) as first-class expressions.
- Event annotations for hooking into Bukkit events.
- Scheduler annotations for recurring or delayed tasks.
- GUI primitives with click and close callbacks.
- PlaceholderAPI integration without any Java.
- Direct Java interop: create objects from other plugins with
new <fully-qualified-name>(...), call static methods, read static fields — no wrappers, no registration.
Features
Language
int / double / bool / string / var with runtime type checks
- Full control flow:
if / else, for, while, do-while, break, continue, return
- Typed functions with overloading, lambdas, and closures
- Structs with fields and member methods (instance + static)
- User-defined enums, comparable directly with strings
- Arrays,
vector (list), set, map, stack, queue
- JSON serialization via
toJson / fromJson
Minecraft integration
- Entity selectors with filters (
limit, distance, level, name, world, gamemode, type)
EntityRef with live fields (p.name, p.health, p.x) and reflected methods
- Placeholders (
$player$, $world$, $server$, $boss$) for soft-dependency features
@EventHandler for Bukkit events, @BukkitRunnable for scheduled tasks
runcmd(executor, command) for dispatching commands (player or console)
- GUI system: create menus, assign icons, register click and close callbacks
Built-ins
- Math:
abs, max, min, sqrt, pow, sin, rand, and many more
- BigDecimal:
bigAdd, bigSub, bigMul, bigDiv, bigDivExact for money-precision arithmetic
- File I/O:
fopen, fread, fwrite, fclose, freadlines, fwritelines, fexists, fdelete
- PlaceholderAPI bridge:
papi, papiSet, papiRegister, papiUnregister, papiHas
Reliability
- Parser errors point to line and column.
- Runtime errors log with a stack trace without crashing the server.
- Optional dependencies (PlaceholderAPI, HimDungeons, WorldEdit) degrade gracefully — scripts still load when they are missing.
Example: Welcome new players
plugins/HimDSL/onServerLoad.himdsl:
@EventHandler
void onJoin(event(PlayerJoinEvent)) {
player p = @s;
runcmd("CONSOLE", "say Welcome " + p.name + " to the server!");
runcmd(p.name, "title @s title {\"text\":\"Welcome\"}");
}
int main() {
start("onJoin");
}
Example: Scheduled autosave
@BukkitRunnable
void autosave() sche = 300s {
var lines = vector();
lines.add("saved at tps=" + $server(tps)$);
fwritelines("last_save.txt", lines);
}
int main() {
start("autosave");
}
Example: Simple shop GUI
int main() {
var gui = new GUI(3, "§6Shop");
var diamond = new GUISlot(Material.DIAMOND);
diamond.name = "§bDiamond";
diamond.lore = {"§7Price: §e100", "§aLeft-click to buy"};
diamond.onLeftClick = () -> {
player p = @s;
runcmd("CONSOLE", "eco take " + p.name + " 100");
runcmd("CONSOLE", "give " + p.name + " diamond 1");
runcmd(p.name, "msg §aPurchased");
gui.close(p);
};
gui[1][4] = diamond;
gui.updateAll();
gui.open(@p);
}
Commands and Permissions
| Command |
Description |
Permission |
/himdsl compile <path> |
Syntax check only |
himdsl.use |
/himdsl run <path> [args] |
Execute a script |
himdsl.run |
/himdsl debug on\|off |
Toggle verbose logs |
himdsl.debug |
/himdsl debug codeon\|codeoff |
Print script content before each run |
himdsl.debug |
All paths are relative to plugins/HimDSL/. All three permissions default to OP.
Requirements
- Server: Bukkit / Spigot / Paper 1.21+ (Paper 1.21+ recommended)
- Java: 25 or later (The newest version allows 17+)
- Optional:
- PlaceholderAPI — enables
papi(...) family
- HimDungeons — enables
$boss(...)$ and dungeon placeholders
- WorldEdit — enables some world placeholders
Auto-run Scripts
Drop these files into plugins/HimDSL/ and they run automatically:
onServerLoad.himdsl — after the server finishes loading
onServerShutdown.himdsl — on plugin unload / server shutdown
Documentation
Full documentation is available on the project Wiki:
- Getting Started, Language Basics, Control Flow
- Functions, Lambdas, Functional Interfaces
- Data Structures, Custom Types, Java Interop
- Minecraft Integration, Events & Scheduling, GUI System
- Built-ins Reference, Advanced Topics, Pitfalls
- Example Scripts (recursion, loops, GUI shop, state machine, mini-game)
For Java Developers
HimDSL exposes a HimDSLAPI through Bukkit's ServicesManager so other plugins can compile, run, and generate scripts:
HimDSLAPI api = Bukkit.getServicesManager().load(HimDSLAPI.class);
if (api != null) {
api.run(new File(himdslFolder, "script.himdsl"));
}
Add softdepend: [HimDSL] to your plugin.yml.
You can see the whole wiki at
License
See the LICENSE file.
Issues & Feedback
Bug reports and feature requests are welcome on the issue tracker.
评论 0
登录后参与评分
还没有评论,来抢沙发吧