JSEngineNK

Experimental JSEngineNK 1.2.0

Compatible API Versions
1.0.0 and higher
Contributors
Creadores Program & RedstoneAlmeida
JSEngineNK
Nukkit plugin, enable to load javascript! very simple create systems!! Nukkit plugin - Allows you to load Javascript modules! Runs ES6 version of partial JavaScript since it doesn't have Class and some stuff
Credits to the Original Plugin: https://cloudburstmc.org/resources/modloader.108/


How to use?
Create javascript archive, example: mod.js
Drop archive in plugins/JSEngineNK/mod.js
Create your code!
Start your server! Instantly run
examples can be found (here) [https://github.com/Trollhunters501/JSEngineNK/tree/master/examples]

Basic JavaScript API loaded!:
Global Variables:
JavaScript:
var server; return getServer();
var plugin; return ModLoader Plugin MainClass;
var global; return ModLoader Plugin MainClass;
var self; return ModLoader Plugin MainClass;
Object.entries; it's a small polyfill
Object.assign; it's a small polyfill
var manager; return FunctionManager Class, Using to create Commands e Loops
var script; return A class that registers scripts and events
var logger; return Console Logger Input
var console; return Console Logger Input
var window; return Console Logher Input
var fetch; return Fetch API by Creadores Program


var players; return All Online Players
Create Basic Command:
JavaScript:
manager.createCommand("name", "description", "functionUsed");


function functionUsed(sender, args){
    if(args.length < 1){ // see args exists
        sender.sendMessage('You used incorrect!');
        return;
    }
    var name = args[0];
    sender.sendMessage("You writer: " + name); // send Message to sender
    // sender.sendMessage(manager.format("You writer: %s", name)); format your message
}
Create Basic Tasks:
JavaScript:
manager.createTask("tasknormal", 20 * 20);

manager.createLoopTask("taskloop", 20 * 20);

function tasknormal(currentTick){
    print('I tasknormal!');
}

function taskloop(currentTick){
    print('I taskloop');
}
Run Events:
JavaScript:
script.addEventListener("PlayerJoinEvent", function(event){
    var player = event.getPlayer();
    player.sendMessage("welcome to Server!");
});
// ready, start your server and test!
See the list of supported Events: https://github.com/Trollhunters501/JSEngineNK/blob/master/Events Soported/Events.md

Create Config:
JavaScript:
var config = manager.createConfig(manager.getFile("folder", "archive"), 2); // 2 = Config.YAML

config.set("key", "value");
config.save();
Register Script:
JavaScript:
script.registerScript({
    name: "TestScript",
    version: "1.0",
    description: "The Test!",
    website: "https://github.com/Trollhunters501/JSEngineNK/",
    authors: ["Creadores Program & RedstoneAlmeida"]
});
//You can register your script so that it appears in the list of scripts with the command /scripts or also with the command /version or /ver
//The mandatory parameters are: author or authors, name, version and description optional: website
Using Packages from nukkit and Java Vanila:
JavaScript:
var playertest = Java.type("cn.nukkit.Player");
//The Player file you can see the Nukkit API in their official documentation on how to use the files! (I recommend using hard to replicate variables as another script may use the same variable)
var IOExeptionTest = Java.type("java.io.IOException");
//java vanilla
var ContentType = Packages.org.apache.http.entity.ContentType;
//Packages which are not in Java Vanila or Nukkit (Necessary to install the Packages )
View scripts by name I recommend using when finished loading all the scripts!):
JavaScript:
script.getScriptByName("here the name of the script!");
Isolated or Private functions: (variables or functions will not be global Neither events nor tasks can be registered):
JavaScript:
//These are isolated functions that means that the variables and functions inside it cannot be executed and neither can events nor tasks be registered!
(function(){
  //code...
})();
Import external libraries by URL:
JavaScript:
//import libraries by URL:
LoadLib("https://github.com/MCFT-Server/Mskyblock/raw/master/Mskyblock.jar", "mskyblock.Main");
//first URL parameter where is the bookshop, second: class to import

//import library:
var test = Packages.mskyblock.Main;
If you want to make plugins for your server, do not hesitate to Contact Us!
Discord: https://discord.gg/mrmHcwxXff20230207_215109.jpg
2023©
Author
Trollhunters501
Downloads
160
Views
395
First release
Last update
Rating
0.00 star(s) 0 ratings

More resources from Trollhunters501

Latest updates

  1. Update 1.2

    bug fix, The Permission to execute the script command was set, the permission is the same as...
  2. Update 1.1

    Added library import by URL (see Description)
  3. Update 1.0.1

    bug fix.
Top