RubyEngineNK

Experimental RubyEngineNK 1.1.0

Compatible API Versions
1.0.0 and higher
Contributors
Creadores Program
RubyEngineNK
Run Ruby on Nukkit!
Requirements:
JSEngineNK Plugin: https://cloudburstmc.org/resources/jsenginenk.939/
JSENK2: https://cloudburstmc.org/resources/jsenk2.1017/
Know Basic JavaScript.

Installation:
Easily installed with a JSEngineNK script:
JavaScript:
const RubyS = require("RubyEngineNK/org/CreadoresProgram/RubyEngineNK.js");
Engine Creation:
Just add this code to your script and you can use Ruby!
JavaScript:
var TestRuby = new RubyS.RubyEngineNK().build();
Eval:
JavaScript:
TestRuby.eval("$getLogger.info('hello world!')");
Default variables:
$getLogger return logger by JSEngineNK
$getServer return server
$manager return manager by JSEngineNK
$plugin return main Class by JSEngineNK

Specify Variables (put):

JavaScript:
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!
setNnClassLoader :
This function does the same thing as JSEngineNK's Nnclassloader API but passed to Ruby example:

JavaScript:
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)

evalFile:
Run Ruby code from a file:
JavaScript:
TestRuby.evalFile(manager.getFile("TestRuby", "Test.rb"));
Java methods from Ruby:

Ruby:
# 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

If you want to make plugins for Nukkit, don't hesitate to contact us! Discord: https://discord.com/invite/mrmHcwxXff
Creadores Program © 2024
Author
Trollhunters501
Downloads
336
Views
675
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from Trollhunters501

Latest updates

  1. Update API

    Update API to JSENK2
  2. JSdelivr Update

    Now the plugin is in JSdelivr!(See description)
Top