-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Pandawa Package is a container for your script, its like plugin jar.
Pandawa Package can contains pandawa.yml to specify more information about the package.
Pandawa Package contains all scripts and resource files.
To create a pandawa package, all you need is to zip the entire script, and also put pandawa.yml in it
(optional). The zip can contains any files or any scripts.
Pandawa Package can be also a Directory/Folder that contains collections of script, pandawa.yml, and
resource files.
- get the pandawa package file (.zip or zipped folder)
- put it in
./plugins/PandawaJS/scripts/
- restart the server or do
/pdw reload
Pandawa Package Properties contains useful data for PandawaJS and for your scripts,
PandawaJS will read pandawa.yml as your package properties and will use it
to load your script. This is optional, if you didn't include this file on your package,
PandawaJS will ignore it and will load all script at the same time, this is also happened
if you don't specify main field on pandawa.yml.
name: PandawaJS # the package name, avoid using name "default" as it will interrupt other packages
author: Septogeddon # the author
main: Main # the main script, in this example case "Main.js" (optional). If defined it will only run Main script, the other script can be called from Main Script
version: # the version string
dependencies: [] # list of dependencies (PandawaPackage dependencies, not Plugin dependencies)
libraries:
- exampleLib # assuming that you have 'exampleLib.jar' on your packagePut that file inside of your package zip or folder.
example file: https://pastebin.com/wM7QHMWR
To do this, you can put the jar on the package folder/zip.
And then put the file name of the library (without.jar, example Shop.jar -> Shop),
on pandawa.yml (if you don't have it then create one.)
See Pandawa Package Properties
See Java Libraries
All Common Java Objects mostly imported by default. Otherwise you have to import it.
Default classes list: https://pastebin.com/raw/phZrZBcH
Packages.java.io.File; // this is basically import the class
Packages.java.io.FileInputStream;
var fis = new FileInputStream(new File("C:/hello.txt"));All java objects imported to this plugin will actually imported as reflection
so, you can get any private fields or call any private methods without using Java Reflection.
Java libraries allows you to do complex things using simple function.
This can be found in ./plugins/PandawaJS/libraries/.
- Apache Commons IO 2.5
- Apache Commons Lang3 3.0
- Gson 2.8.2
- Jsoup 1.11.3
You can add more libraries by placing the jar inside libraries folder.
Bonus: You can add JavaCord to work with Discord bot management!
print something to console
similar to println writeln console.log
check if an object is a player
return true if object is player, false otherwise
deep to string object, could be an array
similar to "new Yaml()"
See Yaml
print Object class name to console, used for debugging purpose
get online player
See Players
colorize the string using bukkit color
return server instance
See org.bukkit.Server
See getServer()
See getServer()
Deprecated and should not be used.
Use Commands['commandName'] instead
See Command builder
Run a task asynchronously (outside of Bukkit thread)
return a Future object that could get the result object of a task if the task returns something
var promise = async(function() {
log('this is async function');
return 'this is awesome');
});
var awesomeString = promise.get();
log(awesomeString); // prints 'this is awesome'Run a task asynchronously with a delay
does not return a Future object
Run a task asynchronously with a delay and run delayed repeatedly
function() - the function
number - delay ticks
number - period ticks
Similar to async but runs synchronously (inside Bukkit thread)
Similar to async but runs synchronously (inside Bukkit thread)
Similar to async but runs synchronously (inside Bukkit thread)
convert seconds to ticks
convert minutes to ticks
convert hours to ticks
convert days to ticks
This class allows you to create GUI
var gui = new GUI(title,size);
var gui = new GUI(title,InventoryType);See org.bukkit.inventory.InventoryType
var gui; // the gui
gui[0] = Items.APPLE; // put an Apple to slot 0
gui[1] = Items.GOLDEN_APPLE.executor(function(event) {
log('Golden Apple is clicked');
}); // put a Golden Apple with executor in it to slot 1var gui; // the gui
gui.open('Septogeddon');
//or
gui.open(Players.Septogeddon);
gui.open(Players['Septogeddon']);var gui; // the gui
gui.clear();var gui; // the gui
gui.closeAll(); // all players that viewing the GUI, will be closed.GUIBuilder#open(Object) open the gui to a player
GUIBuilder#fillEmpty(Item) fill empty the gui
GUIBuilder#fill(Item) fill the gui
GUIBuilder#clear() clear the gui
GUIBuilder#closeAll() close all viewers
This class allows you to load .yml files
var yaml = new Yaml();
var yaml = createConfig();
var yaml = Files['config.yml'].loadConfig();
var yaml = new Yaml(Files['config.yml']);var yaml; // the instance
yaml.paths;
yaml['paths']['anotherpath'];
yaml.balance.Septogeddon;
yaml.balance['Septogeddon'];var yaml; // the instance
yaml.paths = 'nothing';var yaml; // the instance
delete yaml.paths;
//or
yaml.paths = null;var yaml; // the instance
Files['config.yml'].write(yaml);This class allows you to listen to plugin events
Hooks.onDisable(function() {
// codes run when PandawaJS is disabling
});This class allows you to get net.minecraft.server.$version classes
NMS.PacketPlayOutChat;
NMS['EntityPlayer'];This class allows you to get org.bukkit.craftbukkit.$version classes
CraftBukkit.CraftServer;
CraftBukkit['CraftServer']Similar to CraftBukkit
See CraftBukkit
An enum to inventory types
See org.bukkit.inventory.InventoryType
This allows you to register a command
var cmd = Commands['commandName']var cmd;
cmd.also('aliasName');
cmd.alias('aliasName'); // alias = also
cmd.also('aliasName').also('aliasName2').alias('aliasName3');var cmd;
cmd.permission('permission.example');
cmd.permissionMessage('You dont have permission fool!');var cmd;
cmd.executor(function(sender,args)) {
// sender is org.bukkit.command.CommandSender
// args is String array (String[])
);See org.bukkit.command.CommandSender
var cmd;
cmd.tabcompleter(function(sender,args)) {
// sender is org.bukkit.command.CommandSender
// args is String array (String[])
// must return a String array
return ['completer','here'];
};See org.bukkit.command.CommandSender
var cmd;
cmd.register();var cmd;
cmd.unregister();This allows you to listen Bukkit / Plugin events
var listener = Events['event name']
var listener = Events['com.example.plugin.events.ExamplePluginEvent']
var listener = Events['player.PlayerJoinEvent']var listener; // listener builder instance
listener.listen(function(event)) {
//do something with the event
});
// #listen(PRIORITY, FUNCTION)
listener.listen('LOWEST',function(event)) {
//do something with the event
});var listener; // listener builder instance
listener.unregister();This allows you to spawn an Entity
var entity = Entities.ENTITY_TYPE;
var entity = Entities.ARMOR_STAND;
var entity = Entities['ARMOR_STAND']var entity;
var playerExample;
entity.spawn(LOCATION);
entity.spawn(new Location(Worlds['world_nether'],10,10,10));
entity.spawn(playerExample.getLocation());See org.bukkit.Location
See org.bukkit.entity.Player
This allows you to create an Item
Items.APPLE;
Items['APPLE'];Available Functions
ItemBuilder#executor(function(clickEvent)); Set the executor for GUI Click
ItemBuilder#name(String) set the display name
ItemBuilder#lore(String...) set the lore
var item;
item.lore('this','is','multiple','line','lore');ItemBuilder#meta(function(meta)); consume the ItemMeta
See org.bukkit.inventory.meta.ItemMeta
ItemBuilder#flag(String...) set the flags
See org.bukkit.inventory.ItemFlag
var item;
item.flag('HIDE_ENCHANTS');
item.flag(); // will use all flags
item.flag('HIDE_ENCHANTS', 'HIDE_UNBREAKABLE');ItemBuilder#unbreakable(boolean) set unbreakable
ItemBuilder#type(String) set the type
ItemBuilder#amount(number) set the amount
ItemBuilder#enchant(String,level) add the enchantment
See org.bukkit.enchantments.Enchantment
ItemBuilder#unenchant(String) remove the enchantment
and more from org.bukkit.inventory.ItemStack
This allows you to control file from your script package configuration folder ("./plugins/PandawaJS/configurations//")
Files['config.yml']FileStreamer#input() return InputStream
FileStreamer#output() return OutputStream
FileStreamer#reader() return Reader
FileStreamer#writer() return Writer
FileStreamer#write(Object) write Stringified Object
FileStreamer#readAll() read file and return String
FileStreamer#loadConfig() read file as Yaml config
FileStreamer#copy(InputStream) write from inputstream
and more from java.io.File
This allows you to create PotionEffect object to apply on a LivingEntity (player, animals, monsters, creature)
Potions['SPEED'];
Potions.JUMP;See org.bukkit.potion.PotionEffectType
PotionBuilder#apply(LivingEntity) could be applied to Player, ArmorStand, Wolf, Zombies, etc
See org.bukkit.entity.LivingEntity
PotionBuilder#type(String) set the Potion effect type
PotionBuilder#ambient() return boolean ambient state
PotionBuilder#ambient(boolean) set ambient state
PotionBuilder#particles() return boolean particles state
PotionBuilder#duration() return duration in tick (integer/number)
PotionBuilder#duration(number) set the duration (in ticks)
PotionBuilder#amplifier() return the amplifier level
PotionBuilder#amplifier(number) set the amplifier level
This class controls aspect of your script
Default package name is 'default' can be get by Packages.default or Packages['default']
Package#getName() return the package name
Package#getAuthor() return the author
Package#getVersion() return the package version
Package#getDependencies() return the dependencies list
Package#getMainScript() return main script name
Package#getScript() return a script
See Pandawa Script
Package#getAPI() return PandawaJS API
See PandawaAPI
Package#getPandawa() get the core, See Pandawa
This class is basically class to hold your script.
All functions and variables are shareable.
var script1 = Scripts['ScriptExample'];
script1.doTheThing(); // this will call function 'doTheThing' from script1 (ScriptExample)PandawaAPI#registerImp(String,PandawaImpPackage)
PandawaAPI#unregisterImp(String)
PandawaAPI#getDefaultPackage()
PandawaAPI#getPackage(String)
PandawaAPI#getLoadedPackages()
PandawaAPI#readPandawa(File)
PandawaAPI#registerImplementation(Object)
Pandawa#getPackage() get the package
Pandawa#queueLoad() avoid using this
Pandawa#getResource() get the resource file inside pandawa (from .zip or directory) See PandawaResource
See Pandawa Resource
PandawaResource#getName() get the resource/file name
PandawaResource#openStream() create new InputStream for this resource
PandawaResource#getPackage() get package owner
PandawaResource#saveResource() save the resource
This allows you to request event from Player
Requests.CHAT;
Requests.CLICK;
Requests['CHAT'];
Requests['CLICK'];var req = Requests.CHAT;
req.request(Players.Septogeddon, function(event) {
Players.Septogeddon.sendMessage('You just chat: '+event.getMessage());
});See org.bukkit.event.player.AsyncPlayerChatEvent
var req = Requests.CLICK;
req.request(Players.Septogeddon, function(event) {
Players.Septogeddon.sendMessage('You just chat: '+event.getClickedBlock());
});See org.bukkit.event.player.PlayerInteractEvent
var req; // request builder instance
req.cancel('PlayerName');
req.cancel(Players.Septogeddon);returns a Command builder.
Commands['commandName']
Commands.commandNameWithoutSpaceSee Command Builder
returns a Player (Online Player)
Players.Septogeddon
Players['Septogeddon']
for (var player in Players)returns a World
Worlds.world_nether
Worlds['world_the_end']
for (var world in Worlds)returns a Listener builder
Events[PlayerJoinEvent] // since 1.0.28
Events['player.PlayerJoinEvent']
Events['org.bukkit.event.player.PlayerJoinEvent']See Listener builder
returns an Entity builder
Entities.ARMOR_STAND
Entities['ARMOR_STAND']See Entity builder
returns an Item builder
Items.GOLDEN_APPLE
Items['APPLE']See Item builder
See org.bukkit.inventory.ItemStack
returns a File streamer
Files['config.yml']See File Streamer
See java.io.File
returns a Potion builder
Potions.CONFUSION
Potions['SPEED']See Potion Builder
See org.bukkit.potion.PotionEffectType
returns a Pandawa Package
Packages['default']
Packages.SeptogeddonJSPacksSee Pandawa Package
returns a Pandawa Script
Scripts['SimpleSystemInformation']
Scripts.SimpleGUISee Pandawa Script
returns a Main Plugin Instance
Plugins['WorldEdit']
Plugins.EssentialsSee org.bukkit.plugin.Plugin
See org.bukkit.plugin.java.JavaPlugin
Used to debug the plugin, should not be used.
returns Request Builder
Requests.CHAT;
Requests.CLICK;See Request Builder
returns PandawaResource
Resources['pandawa.yml'];See Pandawa Resource
returns Java Package
JavaPackages['org.jsoup.Jsoup'];
JavaPackages.org.jsoup.Jsoup;