- Compatible API Versions
- 1.0.0 and higher
- Sourcecode
- https://github.com/shendepu/nashorn-polyfill https://github.com/walterhiggins/commonjs-modules-javax-script https://github.com/Trollhunters501/Fetch-API-Nashorn/
- Contributors
- walterhiggins, shendepu


Requirements:

ModLoader
ModLoader Nukkit plugin, enable to load javascript! very simple create systems!! How to use? Create javascript archive, exemple: mod.js Drop archive in plugins/ModLoader/mod.js Create your code! Start your server! Instantly run Refs...

How to install:
Put the ZIP file in the ModLoader folder then unzip the file and start the server and Voila! (Remember to delete the ZIP file)
How to use:
You will be able to use the Browser JavaScript APIs that are Compatible (I recommend to see the source code links)
BlobAPI.js:
Add JavaScript or Browser Blob more information: https://developer.mozilla.org/es/docs/Web/API/Blob
GlobalAPI.js:
Add console.info(); console. warn(); self, global, process, etc.
HttpAPI.js:
Add the HttpServletRequest API!.
requireAPI.js:
Add the JavaScript function require();
TimeAPI.js:
Add setTimeout, setImmediate and setInterval API and also clearTimeout, clearImmediate and clearInterval.(I don't know what it would be used for if ModLoader already implements this in its tasks, the only thing that changes is that ModLoader is in Minecraft ticks and this is in Milliseconds)
Load Jars.js
Add that we can implement libraries or Packages that we need in our Script, you only need to compile the libraries or Packages, that is, convert them to .jar files
How do I load the library?
You must use the loadJars() function:
JavaScript:
loadJars([
//here the absolute directory in Linux is /home (you can investigate how it is in each system) in hosters it is almost always the same as the path that appears above in the file explorer
"/home/container/Jars/MyPackage.jar"
]);
//now you can use it
var Myclass = Java.type("MyPackage.example.codeClass");
//or
var Myclass = Packages.MyPackage.example.codeClass;




Fetch API.js:
Adds the Fetch Browser feature to access HTTP servers! (Also to Websites!)


How does it work:
Here an example of POST and GET!
JavaScript:
//How to make a GET request
var requestGET = fetch("https://theurltest.com", "GET");
console.info("The page say: " + requestGET);
//It also works without putting "GET" example:
var requestGET2 = fetch("https://theurltest.com");
console.info("The page say: " + requestGET2);
//How to make POST request
var requestPOST = fetch("https://theurltest.com", "POST", JSON.stringify({
content: "Content you send to the server, You can also obviously add more variables as you need just like Fetch!"
}));
//If the server sends a message you can receive the message!
console.info("The server says: " + requestPOST);
--




If you want to know how to better use ModLoader I recommend you visit my blog where I talk about it:
API de ModLoader de Nukkit
Amigos he hecho esto porque la información del Plugin ModLoader de Nukkit (Que ejecuta JavaScript en Nukkit) es muy Básica y he decidido ex...
