Run Ruby on Nukkit!
JSEngineNK Plugin: https://cloudburstmc.org/resources/jsenginenk.939/ And JSENK2: https://cloudburstmc.org/resources/jsenk2.1017/
Know Basic JavaScript.
Just add it in dependencies of your JSENK2 script and put the file in the plugins/JSENK2 folder
Example:
const RubyS = require("RubyEngineNK/org/CreadoresProgram/RubyEngineNK.js");
Just add this code to your script and you can use Ruby!
var TestRuby = new RubyS.RubyEngineNK().build();
TestRuby.eval("$getLogger.info('hello world!')");
$getLogger return logger by JSEngineNK
$getServer return server
$manager return manager by JSEngineNK
$plugin return main Class by JSEngineNK
TestRuby.put("localVariable", objectJava);//cannot be used in functions or classes only outside
TestRuby.put("$globalVariable", objectJava);//Can be used everywhere
TestRuby.put("CONSTVARIABLE", objectJava);//constant variable constant variable
//also applies to setNnClassLoader!
This function does the same thing as JSEngineNK's Nnclassloader API but passed to Ruby example:
TestRuby.setNnClassLoader({ urls: ["https://test.com/test.jar"] }, {
$global: "class.example"//...
});
It also has most of the features of PHPEngineNK (minus code conversion and print)
Run Ruby code from a file:
TestRuby.evalFile(manager.getFile("TestRuby", "Test.rb"));
# Import as Java import
require 'java' #import java
java_import "cn.nukkit.Server" # Can be used as in Java without specifying, just use Server or the class name
# more info: https://github.com/jruby/jruby/wiki/CallingJavaFromJRuby
You can implement Listener events in Ruby (using Java headers and everything necessary to implement in Ruby with the engine) More Info: https://github.com/jruby/jruby/wiki