Archduke's Nashorn Console
- Tested Minecraft Versions:
Easy, just drop into the plugins folder, and then optionally modify config.yml.
Running Java from Nashorn - https://docs.oracle.com/javase/8/docs/technotes/guides/scripting/nashorn/api.html
Spigot API (1.12) - https://hub.spigotmc.org/javadocs/spigot/overview-summary.html
The /invoke command does not by default give permission to OPs. This is because the command is very powerful, and can run any arbitrary code on the server, including code that may ban players, modify permissions, change blocks, create entities, overwrite files, create network connections, or crash the server. Do not give /invoke permission to anyone on your server that you don't have absolute, complete trust in!
If you do want to allow OPs to use /invoke, change allowOps in config.yml to true. No restart is required.
Slightly advanced notes
Declared variables in global scope persist for as long as the server is online.
The result of an expression is written in "> gray"
Text written to standard out is written in white.
Text written to standard error is written in red.
Exceptions thrown by Nashorn or Java are written in red.
Developers who modify the code (and you can decompile it if you want) may replace Nashorn with any other JSR-223 compliant ScriptEngine.
At least Java 8 is required.
There should be no dependencies on any specific version of Spigot, so it should be version-agnostic.
(the source code isn't here because I have yet to get it hosted somewhere. In the meanwhile you can decompile the plugin.)