Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Add
  • Loading branch information
Trollhunters501 authored Oct 25, 2023
1 parent c69d1e8 commit 4430fe1
Showing 1 changed file with 71 additions and 13 deletions.
84 changes: 71 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@ Credits to the Original Plugin: https://cloudburstmc.org/resources/modloader.108
- 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 plugin; return JSEngineNK Plugin MainClass;
var global; return JSEngineNK Plugin MainClass;
var self; return JSEngineNK Plugin MainClass;
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
Expand Down Expand Up @@ -117,18 +114,79 @@ isolated or private function
})();
```

Import external libraries from java by URL:
Import external libraries from java by Maven:
```javascript
//import libraries from java 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;
//import libraries from java by Maven:
// Define Maven dependencies for the script
var MAVEN_DEPENDENCIES = ['com.h2database:h2:1.4.192', 'org.apache.commons:commons-dbcp2:2.1.1'];
// Create class loader instance.
var L = new NnClassLoader({ maven: MAVEN_DEPENDENCIES });
// Look at the actual list of jars resolved by the class loader.
for each(var url in L.getUrls()) print(url);
// Import class similarly to Java.type
var BasicDataSource = L.type('org.apache.commons.dbcp2.BasicDataSource');
// Work with imported classes as usual
var ds = new BasicDataSource();
// ...
```
Import external libraries by URL:
```javascript
//import libraries by URL
load("https://example.com/exam.js");
//Done!
```
To see all manager functions go to [https://github.com/Trollhunters501/JSEngineNK/blob/master/Manager info/ManagerFunc.md]

How to create JavaScript Classes:
```javascript
//You must create a const variable with the Class() function and with 2 parameters The name of the variable will be the name of your class!

//The first parameter is always Object except if you want to extend another JavaScript class In that case just change Object to the name of the class (The class should have already been established)
//The second parameter is the class functions!(If you extend any class, for no reason do you give your functions the same name as the extended classes (The JavaScript engine gets confused and crashes))
const Says = Class(Object, {
say: function(){
console.info('Hello');
}
});
//Create a call to the class:
var Hey = new Says();
//Call the function:
Hey.say();
//Output: Hello


//Extend a Class:
//Extends the previous class
const Greeting = Class(Says, {
//Respecting that the function is not repeated, in this case you cannot repeat say()
hi: function(){
//Call to the class that extends:
this.say();
//Plus extra code
console.info('Console!');
}
});
//We call the class the same as before
var HiCon = new Greeting();
HiCon.hi();
//Output: Hello
//Console!


//Done!
```

Default libraries in the plugin:
Fetch: https://raw.githubusercontent.com/Trollhunters501/Fetch-API-Nashorn/main/Creadores Program/Nashorn NK/Fetch API.js
UnderScoreJS: https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.13.6/underscore-min.js
Loadash: https://cdn.jsdelivr.net/npm/lodash@4/lodash.min.js
RequireAPI: https://raw.githubusercontent.com/walterhiggins/commonjs-modules-javax-script/master/require.js
Base64: https://raw.githubusercontent.com/Trollhunters501/JSEngineNK/master/libs/base64.js
Adder: https://raw.githubusercontent.com/maheshrajannan/java8Nashorn2/master/src/main/java/java8Group/java8Artifact/js/adder.js
NnClassLoader: https://cdn.rawgit.com/NashornTools/NnClassLoader/master/NnClassLoader.js
ES6 from Nashorn: https://raw.githubusercontent.com/aesteve/nashorn-es6/master/src/main/resources/es6-shim.js
Class from Nashorn: https://raw.githubusercontent.com/Trollhunters501/JSEngineNK/master/libs/Clases.js

If you want to make plugins for your server, do not hesitate to Contact Us!
Discord: https://discord.gg/mrmHcwxXff
WhatsApp channel: https://whatsapp.com/channel/0029Va5bITcGZNCqyYkDYZ0F

0 comments on commit 4430fe1

Please sign in to comment.