This repository has been archived by the owner on May 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Dragonet JavaScript Plugin Scripting
The Evil Man edited this page Jun 25, 2015
·
1 revision
A DragonetAPI Script ("DAPIS") is a JavaScript that can directly interact with the Dragonet server. Hopefully, after some heavy development, this could be similar to ModPE Scripts for MC:PE, and they could be used interchangeably. Additionally, each plugin is treated like a normal Bukkit plugin which means you can use any of the Bukkit APIs with ease.
Example:
var Server = new ServerAPI(); //'Imports' the ServerAPI
var me; //Create variable to store Bukkit instance in
function onLoad(script){
me = script; //Do the saving. This isn't completely necessary for this script, but it's good to get in the habit.
}
function Tick()
{
Server.clientMessage("Server Tick!"); //Broadcasts "Server Tick!" to the server
}
Save that code as a file with a .js
extension and plop it in your plugins
folder, and the next time you launch Dragonet, "Server Tick!"
will be printed every tick (0.05
of a second) to the server.
-
Tick()
- Called every server tick (twentieth of a second) -
useItem(blockX, blockY, blockZ, blockFace, blockName, playerName)
- Called whenever an item is used. -
destroyBlock
- Called whenever a block is destroyed (In Development) -
onConnect(playerName)
- Called whenever a client connects to the server -
onQuit(playerName)
- Called whenever a client leaves the server (and was not kicked) -
onKick(playerName, kickReason)
- Called whenever a player is kicked -
onCommand(sender, cmdLabel, alias, args)
- Port of Bukkit's hook by the same name. Please note that 'args' is a string array. -
onLoad(Script currentScript)
,onEnable()
,onDisable()
- The same methods as Bukkit's, except for one thing: 'onLoad''s parameters include the Bukkit representation of the current script, which is useful for registering commands and the like. It's recommended you save this for later.
Note: The example of command registration has been moved to the ScriptAPI page, where a more detailed explanation is present.
-
PlayerAPI
- Edit the attributes of players. -
WorldAPI
- Edit, delete or create new worlds -
ServerAPI
- Maintain the server, ban players, run commands and modify chat. -
ConfigAPI (In development)
- Create, read, edit, and delete configuration files. -
PermissionsAPI (In development)
- Manages permissions for the server -
ScriptAPI
- Customize the DragonetAPI by adding new functions, methods and commands.
-
kill(player)
- Kills the provided player -
addItemInventory(player, materialName, Count)
- Adds the specified material to the provided player's inventory -
clearInventory(player)
- Clears the player's inventory -
getCurrentWorld(player)
- Gets the player's current world's name -
setHealth(player, health)
- Sets the playerplayer
's health to the doublehealth
-
getHealth(player)
- Returns the playerplayer
's health in a double -
getX(player)
- Returns the playerplayer
's X coord -
getY(player)
- Returns the playerplayer
's Y coord -
getZ(player)
- Returns the playerplayer
's Z coord
-
setArea(worldName, x1, y1, z1, x2, y2, z2, materialName, tileData)
- Sets the area inside the coords provided in the worldworldName
tomaterialName
with the data oftileData
-
setBlock(worldName, x, y, z, materialName, tileData)
- Sets the block at the specified coords in the worldworldName
tomaterialName
with the data oftileData
-
dropItem(worldName, x, y, z, materialName, Count)
- Drops an item of the typematerialName
at the specified coords -
getBlockAt(worldName, x, y, z)
- Returns the block at the specified coords
-
banPlayer(player, reason)
- Bans the playerplayer
for the reasonreason
-
clientMessage(message)
- Broadcasts the messagemessage
to the server -
disconnectPlayer(player, message)
- Kicks the playerplayer
with the reasonmessage
-
getName()
- Returns the server's name (in the server.properties file) -
runConsoleCommand(command)
- Runs the specified commandcommand
(the '/' cannot be used before the command) -
stop(msg)
- Kicks everyone on the server with the reasonmsg
and stops the server -
getServer()
- Returns the server -
getPlugins()
- Returns an array containing all of the enabled plugins (not scripts) -
logMessage(message, type)
- Logs the messagemessage
to the server's console. Can be adebug
,error
,trace
,warn
orinfo
message.
-
create(config)
- Creates a new directory in the 'plugins' folder with the nameconfig
and creates a .yml file with the same name -
exists(config)
- Returnstrue
orfalse
depending on if the specified config fileconfig
(don't use the .yml extension) exists -
readEntry(config, entry)
- Returns the value of the entryentry
in the config fileconfig
or, if the entry does not exist, "EMPTY_NODE"
The ScriptAPI's documentation is located here.