EasyScript
A Bukkit plugin to allow plugin development in various languages including support for command registration and handling all events.
- Support for multiple scripting languages (Python, JavaScript are known to work).
- Ability to hook into any bukkit event.
- Support for registering bukkit command handlers.
- Support for autoreloading of script files when they change.
- Open Source License
- Supports JavaScript
- Supports Groovy
- Supports Ruby
- Supports Python
- Includes basic examples for supported languages.
Originally developed for dreamcraft.org.
Some trivial example scripts can be found here.
Commands
/script <name> <arguments>
Permission: easyscript.script
Execute a named script with the arguments specified, searches configured script directories for a file called <name>.<suffix> where <suffix> is the suffix for the language, for example js for JavaScript and py for Python.
/scriptreload
Permission: easyscript.scriptreload
Force any scripts and libraries to be reloaded.
Configuration
autoreload
Default: false
If set to true, automatically recompile scripts when they are modified.
language
Default: JavaScript
The programming language scripts will be written in.. The plugin includes support for Groovy, Ruby and Python, you can also add other languages by dropping a JSR 223 compliant scripting runtime jar into the libDirectory. Java includes support for JavaScript, though a lot of the syntax has changed between JDK 1.7 and JDK1.8 due to using a different Javascript engine (Nashorn in 1.8, and Mozilla Rhino before that).
libDirectory
Default: lib
The path to load extra jar files from, the first time the plugin is loaded, the included groovy, ruby and python jars will be extracted to this location. You are free to delete any language runtime jars you are not using, they will only be recreated if the lib directory does not exist when the plugin starts.
useScriptScope
Default: true
When invoking scripts via the /script command, given them their own scope so that their globals are private, if false they will execute in the same context as library scripts. You should leave this true unless you use JRuby, which unfortunately has an issue with handling scopes correctly.
systemProperties
Default: none
System properties to set before creating a script engine. Some script engines use system properties to control their behaviour, the default configuration includes many of these with sensible defaults.
libraries
Default: library
List of script files to load as libraries. Libraries have the ability to hook into Bukkit events, and any functions they provide are available to scripts executed via /script. The default looks for a file called 'plugins/EasyScript/library.js', you can add as many as you want, and split up functionality between library scripts sanely.
scripts
Default: scripts
List of directories under plugins/EasyScript to search for named scripts when a user executes /script <name>. By default /script searches for named scripts under plugins/EasyScript/scripts/<name>.js.
I'm trying to run this on my server which is running Java 1.8. This what I get.
[18:59:31 INFO]: [EasyScript] Enabling EasyScript v2.0-jetty [18:59:31 INFO]: [EasyScript] Creating classloader for language runtime: [file:/home/minecraft/plugins/EasyScript/lib/groovy-all-2.3.7.jar, file:/home/minecraft/plugins/EasyScript/lib/jruby-complete-1.7.16.jar, file:/home/minecraft/plugins/EasyScript/lib/jython-standalone-2.5.3.jar] [18:59:31 ERROR]: [EasyScript] Script engine named: javascript not found, disabling plugin. [18:59:31 INFO]: [EasyScript] Disabling EasyScript v2.0-jetty
Isn't JS scriptengine included with java?
Hey! This looks like an amazing plugin, especially since I am learning JavaScript in school. The only problem is that the installation instructions are outdated and I am having trouble installing the plugin onto my server. Could you (or anyone else) provide a decent step by step tutorial of some sort? Thanks!
It is a very fascinating work! Is this plugin support other plugins' API? What should I do if I want write a script that support other economy plugin? for example, I want to write a script to add other player's money using Essentials plugin.
@cyberiantiger
I was thinking there was probably a better way, thanks! Your example is super easy to understand too, kudos!
@nullschritt
It is possible to do this from Javascript, however you might be better off doing it with Java.
Here's an example script:
http://pastebin.com/C0CkuPFc
How would I go about making http requests with this? Will typical AJAX work, or should I use another method?
The plugin should work with 1.6 and the latest 1.7, if it doesn't, report a bug on the bug tracker.
@TBotV63
Really :( Nothing?!
No Update for 1.6? ;(
Wow... If this does everything it claims to, that is seriously impressive. Well done.
Edit: How do I make scripts auto-run (not require a trigger or command to run)?
@TimTomTim
I've gotta update the documentation, the JavaScript engine in the latest Java 1.7 is *passable*. The one shipped with Java 1.6 is terrible. Though I think for shits and giggles I'm going to try writing some scripts in jython or jruby next. I developed against Java 1.6 and only thought to see if 1.7 shipped a half decent JS engine after writing the docs.
I have a hosted server, I installed that Rhino thing and it still didn't work Edited later: Okay like 30 minutes after i reloaded the scripts it started working.