Files
hamster-script/README.md
2024-08-09 01:24:21 +08:00

34 lines
1.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# hamster-script
为Minecraft服务器导入 [Nashorn](https://github.com/openjdk/nashorn) 引擎来执行 JavaScript 脚本
# 手动构建
1. 将源代码下载或克隆至本地
2. 在源代码根目录中打开命令行窗口
3. 命令行窗口中执行`./gradlew clean build`
4. 构建成品在 `build` 文件夹
也可访问我的 [Jenkins网站](https://jenkins.airgame.net/job/opensource/job/hamster-script/) 获取最新版
# 指令
> JavaScript 代码执行时,执行命令的对象(玩家或控制台)会作为 sender 变量传入
| 指令 | 权限 | 描述 |
|:--------------------|:---------------------|:------------------------|
| /script eval {脚本内容} | hamster.script.admin | 直接执行 JavaScript 脚本 |
| /script run {脚本文件} | hamster.script.admin | 执行文件中的 JavaScript 代码 |
| /script reload | hamster.script.admin | 重载插件并重设 JavaScript 引擎环境 |
# 注意事项
默认情况下禁止使用 `/script eval {脚本内容}` 指令。
如有需要,可以在 `config.yml` 中将 `enable-eval-command` 设置为 `true` 并重载插件以启用该子指令。
# nashorn 学习资料
- [介绍 Nashorn —— Java 8 JavaScript 引擎](https://mouse0w0.github.io/2018/12/02/Introduction-to-Nashorn/)
- [Oracle Nashorn面向 JVM 的下一代 JavaScript 引擎
](https://www.oracle.com/technical-resources/articles/java/jf14-nashorn.html)