Tags
Creators
Details
6.4
Compatibility
Changes
HimDSL 6.4 发布说明
HimDSL 6.4 Release Notes
概述
Overview
本次更新是 HimDSL 发布以来的一次大改动,引入了权限分级、异常处理、多分支选择以及真正的多维数组。 This release is a large update since HimDSL was first published, introducing permission tiers, exception handling, multi-branch selection, and true multi-dimensional arrays.
脚本能力的边界第一次被显式定义,服务器管理员可以放心地让更多人来写脚本。 The boundary of script capabilities is now explicitly defined, so server administrators can safely let more people write scripts.
新增特性
New Features
1. 安全分级系统
1. Security Tier System
引入 trusted / normal / sandbox 三个权限级别。 Introduces three permission tiers: trusted / normal / sandbox.
默认级别为 normal,兼顾功能与安全。 The default level is normal, balancing functionality and safety.
脚本级别由相对路径的 glob 规则决定,而非硬编码。 The script level is determined by glob rules on relative paths, not hardcoded.
2. 能力模型
2. Capability Model
所有副作用操作被抽象为「能力」(Capability)。 Every operation with side effects is abstracted as a "Capability".
包括文件读写、命令执行、类加载、反射调用、GUI、事件监听、选择器等。 These include file I/O, command execution, class loading, reflection, GUI, event listeners, selectors, and more.
每个级别拥有一个能力集合,配置可自由调整。 Each level has a set of capabilities, fully configurable.
3. 黑名单安全策略
3. Blacklist-Based Security Policy
不再要求服主枚举「允许的包」,改为「默认放行、显式禁止」。 Server owners no longer need to enumerate "allowed packages"; the policy is now "allow by default, deny explicitly".
支持三种黑名单:精确类名、类名前缀、方法名。 Three kinds of blacklists are supported: exact class names, class name prefixes, method names.
trusted 级别绕过全部黑名单检查。 The trusted level bypasses all blacklist checks.
4. 脚本出错中止与资源清理
4. Abort and Cleanup on Script Error
任何未捕获异常都会触发:WARNING 日志 + 立即中止 + 资源清理。 Any uncaught exception triggers: a WARNING log + immediate abort + resource cleanup.
被清理的资源包括定时任务、事件监听器、未关闭的文件句柄。 Cleaned resources include scheduled tasks, event listeners, and unclosed file handles.
每个脚本拥有独立资源域,互不影响。 Each script has its own resource scope, isolated from others.
5. try-catch-finally
5. try-catch-finally
语法与 Java 完全一致,支持具体异常类型和 catch-all 形式。 Syntax is identical to Java, supporting both specific exception types and the catch-all form.
finally 中的 return 会覆盖 try 的返回值,与 Java 语义一致。 A return inside finally overrides the try's return value, matching Java semantics.
PermissionDeniedException 不被脚本捕获,确保审计日志不可被吞掉。 PermissionDeniedException cannot be caught by scripts, ensuring audit logs cannot be swallowed.
6. switch-case-default
6. switch-case-default
语法与 Java 一致,支持 fall-through 贯穿执行。 Syntax matches Java, supporting fall-through execution.
不加 yield,保持经典 switch 语义。 No yield; classic switch semantics are preserved.
case 表达式可以是任意表达式,只在匹配扫描阶段求值一次。 case expressions can be arbitrary expressions and are evaluated only once during the match scan.
7. break 与 continue
7. break and continue
这两个关键字现在真正生效,可用于循环和 switch。 These two keywords now actually work, usable in loops and switch.
switch 中的 break 只跳出 switch,不穿透到外层循环。 A break inside switch only exits the switch, not the enclosing loop.
8. 多维数组
8. Multi-dimensional Arrays
支持一维到 N 维数组的声明、初始化和访问。 Supports declaration, initialization, and access for 1-D through N-D arrays.
支持嵌套初始化器,例如 int a[2][3] = {{1,2,3},{4,5,6}};
Nested initializers are supported, e.g. int a[2][3] = {{1,2,3},{4,5,6}};
维度大小可省略,由初始化器自动推断。 Dimension sizes can be omitted and inferred from the initializer.
9. char 类型
9. char Type
新增 char 关键字,作为数组和变量的元素类型。 The char keyword is added as an element type for arrays and variables.
char 数组的默认元素值为 '\0'。
The default element value of a char array is '\0'.
10. 结构体数组
10. Struct Arrays
支持以结构体类型声明数组,例如 Pos stack[1024];
Supports declaring arrays of struct types, e.g. Pos stack[1024];
数组元素在声明时即被实例化,字段自动置空。 Array elements are instantiated at declaration time, with fields set to defaults.
改进
Improvements
安全上下文现在会跨线程传播,延迟任务和事件监听器中同样生效。 The security context is now propagated across threads, effective in delayed tasks and event listeners as well.
LambdaValue 生成的函数式接口实例会捕获创建时的安全上下文。 Functional interface instances produced by LambdaValue capture the security context at creation time.
配置文件结构清晰化,首次启动自动生成带注释的默认配置。 Configuration files are now clearly structured, with a commented default generated on first startup.
异常信息更友好,包含脚本 ID、级别、触发的能力。 Exception messages are friendlier, including script ID, level, and the capability that triggered the denial.
修复
Bug Fixes
修复了 break / continue 在语法层面缺失导致循环控制流为空的问题。
Fixed an issue where break / continue were missing at the grammar level, leaving loop control flow empty.
修复了一维数组声明忽略元素类型,导致结构体数组元素变为 Integer 的问题。 Fixed an issue where 1-D array declarations ignored element type, turning struct array elements into Integers.
修复了 SelectorParser.matchRange 中的转义错误。
Fixed an escaping bug in SelectorParser.matchRange.
修复了 HimDSLInterpreter 中的重复 import。
Removed duplicate imports in HimDSLInterpreter.
破坏性变更
Breaking Changes
break 和 continue 现在成为保留字,不能再作为变量名或字段名。
break and continue are now reserved words and can no longer be used as variable or field names.
char 现在是类型关键字,不再是合法的标识符。
char is now a type keyword and no longer a valid identifier.
数组声明语法从单维扩展为多维,一维写法完全兼容。 Array declaration syntax has been extended from 1-D to N-D; 1-D forms remain fully compatible.
升级指南
Upgrade Guide
第一步:备份现有脚本目录。 Step 1: Back up your existing script directory.
第二步:删除旧版 config.yml,让插件重新生成带注释的新版。 Step 2: Delete the old config.yml so the plugin regenerates a commented new one.
第三步:将原 config.yml 中的自定义配置迁移到新文件。 Step 3: Migrate your custom settings from the old config.yml into the new one.
第四步:检查是否有脚本使用 break / continue / char 作为标识符,如有需要重命名。 Step 4: Check whether any scripts use break / continue / char as identifiers; rename them if necessary.
第五步:运行测试脚本验证安全级别判定正确。 Step 5: Run a test script to verify the security level is resolved correctly.
致谢
Acknowledgements
感谢每一位提交反馈和漏洞报告的用户。 Thanks to every user who submitted feedback and bug reports.
你们的报告让 HimDSL 更安全、更可靠。 Your reports made HimDSL safer and more reliable.
反馈
Feedback
问题反馈请提交至项目仓库的 Issues 页。 Please submit feedback via the Issues page of the project repository.
安全漏洞请通过私密渠道联系维护者。 For security vulnerabilities, contact the maintainers through a private channel.
Projects on Modrinth are automatically available through a Maven repository for use with JVM build tools such as Gradle. To learn more about the Modrinth Maven API, click here.
Note: When available, you should use the creator's maven repo instead as it will have transitive dependency information that the Modrinth Maven API does not. You may also end up with duplicate dependencies if you use a mix of Modrinth and non-Modrinth Maven repositories for your dependencies, because the group identifier will be different when served through the Modrinth Maven API.
Maven coordinates:
Version ID:
build.gradle:
repositories {
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
// forRepositories(fg.repository) // Uncomment when using ForgeGradle
filter {
includeGroup "maven.modrinth"
}
}
}
// Standard Gradle dependency
dependencies {
implementation "maven.modrinth:YUhl4KGE:Lk2oDMjr"
}
// Legacy Loom dependency
dependencies {
modImplementation "maven.modrinth:YUhl4KGE:Lk2oDMjr"
}

