# @astorks/lib-smc

> JavaScript CommonJS libraries for ScriptableMC

Latest version **1.17.0-preview1** (published 2021-06-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install @astorks/lib-smc
pnpm add @astorks/lib-smc
yarn add @astorks/lib-smc
bun add @astorks/lib-smc
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.17.0-preview1 |
| Published | 2021-06-13 |
| First published | 2020-02-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.8 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 43 |
| Author | Ashton Storks |
| Maintainers | ashtonj1 |

## Links

- npm: https://www.npmjs.com/package/@astorks/lib-smc
- Repository: https://github.com/astorks/ScriptableMC-Engine
- Homepage: https://github.com/astorks/ScriptableMC-TypeScript#readme
- Issues: https://github.com/astorks/ScriptableMC-TypeScript/issues
- npm.io page: https://npm.io/package/@astorks/lib-smc

## Recent versions

- 1.17.0-preview1 (latest) — 2021-06-13
- 1.3.0 — 2020-08-06
- 1.3.0-preview1 — 2020-07-09
- 1.2.2-preview1 — 2020-06-19
- 1.2.1 — 2020-02-25
- 1.2.1-preview4 — 2020-02-24
- 1.2.1-preview3 — 2020-02-22
- 1.2.1-preview2 — 2020-02-21

## README

# ScriptableMC-Engine

[![GitHub release (latest by date)](https://img.shields.io/github/v/release/astorks/ScriptableMC-Engine?label=ScriptableMC&style=for-the-badge)](https://github.com/astorks/ScriptableMC-Engine/releases/latest)
[![SpigotMC Resource](https://img.shields.io/badge/SpigotMC-Resource-yellow?style=for-the-badge)](https://www.spigotmc.org/resources/scriptablemc-engine.74690/)
![License](https://img.shields.io/github/license/astorks/ScriptableMC-Engine?style=for-the-badge)

Run JavaScript/TypeScript plugins for Minecraft 1.17 using the GraalJS script engine.<br />
Supported Minecraft Versions: Bukkit/Spigot/Paper **1.17**<br />
Previous Minecraft Versions: [Use v1.3.X version of the plugin](https://github.com/astorks/ScriptableMC-Engine/tree/1.3.x) <br />

#### New v1.17.X
**We are switching to a new version numbering to match the supporting minecraft version.**<br />
**New v1.17.X builds of this plugin will only work with Minecraft 1.17+**<br />
**For Minecraft v1.12-1.16 you should use v1.3.X of this plugin.**<br />

**This plugin is in a preview state, there may be breaking changes, missing features, and possibly a few bugs.**<br >
Feel free to create an issue if you find any missing features, bugs, or just have an idea for a great feature to add.

**This plugin requires running your minecraft server with OpenJDK, Standard JDK, or the GraalVM java runtime.**<br >
Most linux servers already use OpenJDK, however if you're running windows or want a fully supported java runtime that supports AOT javascript compilation you can install [GraalVM-CE](https://github.com/graalvm/graalvm-ce-builds/releases/latest).

GraalVM-CE is a free open source java runtime created by Oracle that is pre-packaged with the GraalJS Engine allowing all javascript engine features including AOT compilation of javascript.

## Installing The JavaScript Engine Plugin
##### If your server is running on a Standard JDK
- Download the latest [`ScriptableMC-Engine-JS-Bundled.jar`](https://github.com/astorks/ScriptableMC-Engine/releases/latest/download/ScriptableMC-Engine-JS-Bundled.jar) and place it in your plugins folder.
##### If your server is running on a GraalVM JDK
- Download the latest [`ScriptableMC-Engine-JS.jar`](https://github.com/astorks/ScriptableMC-Engine/releases/latest/download/ScriptableMC-Engine-JS.jar) and place it in your plugins folder.

Take a look at [ScriptableMC-TypeScript](https://github.com/astorks/ScriptableMC-TypeScript) for a full typescript plugin example.
You can take the typescript example and compile it, then directly modify the javascript if you don't want to use typescript.

## Commands and Permissions
##### ScritableMC Base Command
| Command       | Alias         | Description                                           | Permission               |
| ------------- | ------------- |-----------------------------------------------------| ------------------------ |
| `/scriptablemc menu`   | `/smc m`       | Opens an inventory menu that allows you to control the script engines. | `scriptablemc.menu` |
| `/scriptablemc info`   | `/smc i`       | Prints plugin version and all loaded script engine versions if available. | `scriptablemc.info` |
| `/scriptablemc reload`   | `/smc rl`       | Fully reloads all script engines and all script files. | `scriptablemc.reload` |
| `/scriptablemc version`   | `/smc v`       | Check the github releases for any updates. | `scriptablemc.version` |

##### ScritableMC JavaScript Engine Commands
| Command       | Alias         | Description                                           | Permission               |
| ------------- | ------------- |-----------------------------------------------------| ------------------------ |
| `/scriptablemc javascript reload`   | `/smc js rl` `/jsrl`       | Fully reloads the javascript engine and all script files. | `scriptablemc.js.reload` |
| `/scriptablemc javascript execute <source>`   | `/smc js ex <source>` `/jsex <source>`       | Executes javascript source and prints the return value. | `scriptablemc.js.execute` |
| `/scriptablemc javascript file <filePath>`   | `/smc js f <filePath>` `/jsexf`       | Executes javascript file from the scripts folder. | `scriptablemc.js.execute.file` |
| `/scriptablemc javascript pastebin <filePath>`   | `/smc js pb <filePath>` `/jsexpb`       | Executes javascript source from a pastebin. | `scriptablemc.js.execute.pastebin` |

### `/smc javascript execute` Command Example
> `/jsex return 1 + 1` <br>
> ![2](https://i.imgur.com/1MkiDxW.png)

> `/jsex sender.sendMessage(lib.org.bukkit.ChatColor.GREEN + "Hello World!")` <br>
> ![Hello World!](https://i.imgur.com/1dzwpqy.png)


### Third Party Libraries
https://github.com/MinusKube/SmartInvs - Inventory helper library<br />
https://github.com/lucko/helper - MinecraftVersions helper library<br />
https://github.com/jkcclemens/khttp - HTTP helper library<br />
https://github.com/aikar/commands - Built-in commands and auto-completion<br />
https://github.com/tr7zw/Item-NBT-API - NBT helper library<br />
https://github.com/apache/commons-io - FileUtils helper library<br />
https://github.com/graalvm/graaljs - JavaScript engine

---
_Source: https://npm.io/package/@astorks/lib-smc · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
