Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Creating Pandawa Package
- Pandawa Package is a container for your script, its similar 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.
- Installation:
- - 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 (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: 1.0 // the version string
- dependencies: [] // list of dependencies (PandawaPackage dependencies, not Plugin dependencies)
- Put that file inside of your package zip or folder.
- example file: https://pastebin.com/wM7QHMWR
- Managing Java Objects
- 1.0 Using Java Object
- Example:
- Packages.java.io.File;
- Packages.java.io.FileInputStream;
- var fis = new FileInputStream(new File("C:/hello.txt"));
- 1.1 Reflections
- 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.
- Default Implemented Functions
- log(Object)
- print something to console
- similar to println writeln console.log
- isPlayer(Object)
- check if an object is a player
- return true if object is player, false otherwise
- toStringObject(Object)
- deep to string object, could be an array
- createConfig()
- similar to "new Yaml()"
- See Yaml
- identify(Object)
- print Object class name to console, used for debugging purpose
- player(String)
- get online player
- similar to Players[String]
- color(String)
- colorize the string using bukkit color
- similar to ChatColor.translateAlternateColorCodes('&', String)
- getServer()
- return server instance
- See org.bukkit.Server
- $()
- similar to getServer()
- server()
- similar to getServer()
- registerCommand(function(sender,arguments))
- Deprecated and should not be used.
- Use Commands['commandName'] instead
- See Command builder
- async(function() return Object)
- 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
- Example:
- var promise = async(function() {
- log('this is async function');
- return 'this is awesome');
- });
- var awesomeString = promise.get();
- log(awesomeString); // prints 'this is awesome'
- async(function(), number)
- Run a task asynchronously with a delay
- does not return a Future object
- async(function(), number, number)
- Run a task asynchronously with a delay and run delayed repeatedly
- function() - the function
- number - delay ticks
- number - period ticks
- sync(function() return Object)
- Similar to async but runs synchronously (inside Bukkit thread)
- sync(function(), number)
- Similar to async but runs synchronously (inside Bukkit thread)
- sync(function(), number, number)
- Similar to async but runs synchronously (inside Bukkit thread)
- seconds(number)
- convert seconds to ticks
- minutes(number)
- convert minutes to ticks
- hours(number)
- convert hours to ticks
- days(number)
- convert days to ticks
- Default Imported Class
- GUI
- This class allows you to create GUI
- 1.0 Initiate The Class
- Example:
- var gui = new GUI(title,size);
- var gui = new GUI(title,InventoryType);
- See org.bukkit.inventory.InventoryType
- 1.1 Put Items to GUI
- Example:
- 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 1
- 1.2 Open the Inventory to a Player
- Example:
- var gui; // the gui
- gui.open('Septogeddon');
- //or
- gui.open(Players.Septogeddon);
- gui.open(Players['Septogeddon']);
- 1.3 Clearing the GUI
- Example:
- var gui; // the gui
- gui.clear();
- 1.4 Close All GUI Viewer
- Example:
- var gui; // the gui
- gui.closeAll(); // all players that viewing the GUI, will be closed.
- Yaml
- This class allows you to load .yml files
- 1.0 Initiate The Class
- Example:
- var yaml = new Yaml();
- var yaml = createConfig();
- var yaml = Files['config.yml'].loadConfig();
- var yaml = new Yaml(Files['config.yml']);
- 1.1 Get Object from Config
- Example:
- var yaml; // the instance
- yaml.paths;
- yaml['paths']['anotherpath'];
- yaml.balance.Septogeddon;
- yaml.balance['Septogeddon'];
- 1.2 Set Object to Config
- Example:
- var yaml; // the instance
- yaml.paths = 'nothing';
- 1.3 Delete Object from Config
- Example:
- var yaml; // the instance
- delete yaml.paths;
- //or
- yaml.paths = null;
- 1.4 Saving the Config
- Example:
- var yaml; // the instance
- Files['config.yml'].write(yaml);
- Hooks
- This class allows you to listen to plugin events
- 1.0 Listen on Pandawa Plugin Disable
- Example:
- Hooks.onDisable(function() {
- // codes run when PandawaJS is disabling
- });
- NMS
- This class allows you to get net.minecraft.server.$version classes
- 1.0 Getting NMS Classes
- Example:
- NMS.PacketPlayOutChat;
- NMS['EntityPlayer'];
- CraftBukkit
- This class allows you to get org.bukkit.craftbukkit.$version classes
- 1.0 Getting CraftBukkit Classes
- Example:
- CraftBukkit.CraftServer;
- CraftBukkit['CraftServer']
- Craft
- Similar to CraftBukkit
- See CraftBukkit
- InventoryType
- An enum to inventory types
- See org.bukkit.inventory.InventoryType
- Command Builder
- This allows you to register a command
- 1.0 Creating a Command Builder
- Example:
- var cmd = Commands['commandName']
- 1.1 Adding Command Aliases
- Example:
- var cmd;
- cmd.also('aliasName');
- cmd.alias('aliasName'); // alias = also
- cmd.also('aliasName').also('aliasName2').alias('aliasName3');
- 1.2 Setting Permission
- Example:
- var cmd;
- cmd.permission('permission.example');
- cmd.permissionMessage('You dont have permission fool!');
- 1.3 Adding Executor
- Example:
- var cmd;
- cmd.executor(function(sender,args)) {
- // sender is org.bukkit.command.CommandSender
- // args is String array (String[])
- );
- 1.4 Adding Tab Completer
- Example;
- 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'];
- };
- 1.5 Registering the Command
- Example:
- var cmd;
- cmd.register();
- 1.6 Unregistering the Command
- Example:
- var cmd;
- cmd.unregister();
- Listener Builder
- This allows you to listen Bukkit / Plugin events
- 1.0 Creating the Listener
- Example:
- var listener = Events['event name']
- var listener = Events['com.example.plugin.events.ExamplePluginEvent']
- var listener = Events['player.PlayerJoinEvent']
- 1.1 Listening the Event
- Example:
- 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
- });
- 1.2 Unlisten the Listener Builder
- Example:
- var listener; // listener builder instance
- listener.unregister();
- Entity Builder
- This allows you to spawn an Entity
- 1.0 Creating the Builder
- Example:
- var entity = Entities.ENTITY_TYPE;
- var entity = Entities.ARMOR_STAND;
- var entity = Entities['ARMOR_STAND']
- 1.1 Spawning the Entity
- Example:
- var entity;
- var playerExample; // see org.bukkit.entity.Player
- entity.spawn(LOCATION);
- entity.spawn(new Location(Worlds['world_nether'],10,10,10)); // see org.bukkit.Location
- entity.spawn(playerExample.getLocation()); // see org.bukkit.entity.Player
- Item Builder
- This allows you to create an Item
- 1.0 Creating an Item
- Example:
- Items.APPLE;
- Items['APPLE'];
- 1.1 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
- Example:
- 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)
- Example:
- 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
- File Streamer
- This allows you to control file from your script package configuration folder ("./plugins/PandawaJS/configurations/<packageName>/")
- 1.0 Creating the Streamer
- Example:
- Files['config.yml']
- 1.1 Available Functions
- 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 other functions from java.io.File
- Potion Builder
- This allows you to create PotionEffect object to apply on a LivingEntity (player, animals, monsters, creature)
- 1.0 Creating the Builder
- Example:
- Potions['SPEED'];
- Potions.JUMP;
- See org.bukkit.potion.PotionEffectType
- 1.1 Available Functions
- PotionBuilder#apply(LivingEntity) // see org.bukkit.entity.LivingEntity (could be Player, ArmorStand, Wolf, Zombies, etc)
- 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
- Pandawa Package
- This class controls aspect of your script
- Default package name is 'default' can be get by Packages.default or Packages['default']
- Available Functions:
- 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
- Pandawa Script
- This class is basically class to hold your script.
- All functions and variables are shareable.
- Example:
- var script1 = Scripts['ScriptExample'];
- script1.doTheThing(); // this will call function 'doTheThing' from script1 (ScriptExample)
- PandawaAPI
- Functions:
- PandawaAPI#registerImp(String,PandawaImpPackage)
- PandawaAPI#unregisterImp(String)
- PandawaAPI#getDefaultPackage()
- PandawaAPI#getPackage(String)
- PandawaAPI#getLoadedPackages()
- PandawaAPI#readPandawa(File)
- PandawaAPI#registerImplementation(Object)
- Pandawa
- Pandawa#getPackage() // get the package
- Pandawa#queueLoad() // avoid using this
- Pandawa#getResource() // get the resource file inside pandawa (from .zip or directory) See PandawaResource
- PandawaResource
- 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
- Request Builder
- This allows you to request event from Player
- 1.0 Creating the Builder
- Example:
- Requests.CHAT;
- Requests.CLICK;
- Requests['CHAT'];
- Requests['CLICK'];
- 1.1 Requesting a Chat
- Example:
- var req = Requests.CHAT;
- req.request(Players.Septogeddon, function(event) {
- Players.Septogeddon.sendMessage('You just chat: '+event.getMessage()); //see org.bukkit.event.player.AsyncPlayerChatEvent
- });
- 1.2 Requesting a Click
- Example:
- var req = Requests.CLICK;
- req.request(Players.Septogeddon, function(event) {
- Players.Septogeddon.sendMessage('You just chat: '+event.getClickedBlock()); //see org.bukkit.event.player.PlayerInteractEvent
- });
- 1.3 Cancelling Request
- Example:
- var req; // request builder instance
- req.cancel('PlayerName');
- req.cancel(Players.Septogeddon);
- Commands
- It will return a Command builder.
- Usage:
- Commands['commandName']
- Commands.commandNameWithoutSpace
- See Command builder
- Players
- It will return a Player (Online Player)
- Usage:
- Players.Septogeddon
- Players['Septogeddon']
- for (var player in Players)
- See org.bukkit.entity.Player
- Worlds
- It will return a World
- Usage:
- Worlds.world_nether
- Worlds['world_the_end']
- for (var world in Worlds)
- See org.bukkit.entity.Worlds
- Events
- It will return a Listener builder
- Usage:
- Events['player.PlayerJoinEvent']
- Events['org.bukkit.event.player.PlayerJoinEvent']
- See Listener builder
- Entities
- It will return an Entity builder
- Usage:
- Entities.ARMOR_STAND
- Entities['ARMOR_STAND']
- See Entity builder
- Items
- It will return an Item builder
- Usage:
- Items.GOLDEN_APPLE
- Items['APPLE']
- See Item builder
- See org.bukkit.inventory.ItemStack
- Files
- It will return a File streamer
- Usage:
- Files['config.yml']
- See File Streamer
- See java.io.File
- Potions
- It will return a Potion builder
- Usage:
- Potions.CONFUSION
- Potions['SPEED']
- See Potion Builder
- See org.bukkit.potion.PotionEffectType
- PandawaPackages
- It will return a Pandawa Package
- Usage:
- Packages['default']
- Packages.SeptogeddonJSPacks
- See Pandawa Package
- Scripts
- It will return a Pandawa Script
- Usage:
- Scripts['SimpleSystemInformation']
- Scripts.SimpleGUI
- See Pandawa Script
- Plugins
- It will return a Main Plugin Instance
- Usage:
- Plugins['WorldEdit']
- Plugins.Essentials
- See org.bukkit.plugin.Plugin
- See org.bukkit.plugin.java.JavaPlugin
- Test
- Used to debug the plugin, should not be used.
- Requests
- It will return Request Builder
- Usage:
- Requests.CHAT;
- Requests.CLICK;
- See Request Builder
Advertisement
Add Comment
Please, Sign In to add comment