JavaScript Scripting
CoreLib provides a GraalJS-based JavaScript scripting system. Scripts can be invoked from action lists through runjs, runscript, or javascript.
This page summarizes the CoreLib JavaScript scripting system for the English documentation.
Basic Usage
Place scripts under:
text
plugins/EmakiCoreLib/scripts/Common directories include:
text
scripts/
├── global/
├── forge/
├── strengthen/
├── cooking/
├── gem/
├── skills/
├── item/
├── attribute/
├── templates/
└── examples/Example action:
yaml
actions:
- 'runjs script=examples/hello.js'Example script:
js
function main(ctx) {
emaki.logger.info("Hello from Emaki JavaScript.");
if (emaki.player.exists()) {
emaki.player.sendMessage("[EmakiJS] Hello, " + emaki.player.name() + "!");
}
return true;
}Exposed APIs
Scripts can use the injected emaki object:
| API | Purpose |
|---|---|
emaki.context | Read action context, placeholders, attributes, and arguments. |
emaki.player | Read player information and send messages. |
emaki.item | Read contextual ItemStack information. |
emaki.action | Dispatch CoreLib actions from scripts. |
emaki.logger | Write script-prefixed logs. |
emaki.random | Generate random values. |
emaki.state | Store temporary shared state in the current action context. |
emaki.text | Text utility methods. |
Security Notes
The default configuration disables host class lookup, IO, threads, native access, and environment access. Production servers should keep these safe defaults unless they fully understand the risks.