SinkScripts is a plugin which adds support for executing, loading & saving groovy scripts.
It also supports interactive ingame scripting.
Groovy is a programming language which is similar to java.
You can find more information about groovy here.
You will need SinkLibrary v1.9.7 or higher if you want to use this plugin. You can get it here.
You can code while ingame (using the chat)!
Use /script (without any args) to enable and disable the interactive console!
Example:
/script //Enable interactive console int i = Bukkit.getOnlinePlayers().size() return "There are currently " + i + " players online!" .execute /script //Disable interactive console
Commands are prefixed with a . and can be used with the /script command (e.g. /script .execute) and the interactive console
List of commands:
If you don't want to use the interactive console, you can also script using this command: /script
e.g.
/script int i = 5 /script return i /script .execute /script .save test
Variables are splitted into two: Constant and non Constant variables.
Constant variables won't change and will always stay the same. Non-Constant variables are variables which updates with each execution...
Constants:
Non-Constants:
Example Usage:
for(Player p : players) { p.sendMessage(String.format("Hello World! I'm at X:%s, Y:%s and Z: %s! ", x, y, z)); }
These are the default imports:
import de.static_interface.sinklibrary.*; import org.bukkit.block.*; import org.bukkit.entity.*; import org.bukkit.inventory.*; import org.bukkit.material.*; import org.bukkit.potion.*; import org.bukkit.util.*; import org.bukkit.*;
You can of course import other packages too (just type import tdl.package.example)
The scripts are located here:
You can edit or save your script in this folder. The extension needs to be name.groovy
After saving it, you can load it with .load <name>
/** * Example script * Description: sends the current TPS to all online players, and heals every player */ double currentTPS = SinkLibrary.getSinkTimer().getAverageTPS(); String sendPlayers = ""; for (Player player : players) { player.sendMessage(ChatColor.AQUA + "Current TPS: " + currentTPS) player.setHealth(20) if (sendPlayers == "") { sendPlayers = player.getName() } else { sendPlayers += ", " + player.getName() } } return "Message has been send to: " + sendPlayers + "!"
Advanced Example
/** This scripts registers an event listener which is listening for IrcReceiveMessageEvent which is fired by SinkIRC and makes the IRC Bot send that message back (something like an echo). It shows how to use listeners with this plugin, you can also listen for other events... **/ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import de.static_interface.sinklibrary.events.IrcReceiveMessageEvent; class TestListener implements Listener { @EventHandler public void onIrcReceiveMessage(IrcReceiveMessageEvent event) { SinkLibrary.sendIrcMessage(event.getMessage()); } } Bukkit.getPluginManager().registerEvents(new TestListener(), plugin);
There is only one permission, because if you can execute scripts, you don't need any other permission, because you can give with this even yourself op! So be careful when giving this permission:
sinkscript.execute: Allows to use this plugin
Development builds of this project can be acquired at the provided continuous integration server. These builds have not been approved by the
BukkitDev staff. Use them at your own risk. They may be also unstable.
Link: http://ci.static-interface.de/job/SinkScripts/lastBuild/
This plugin is Open Source!
http://github.com/adventuria/sinkscripts
Pull Requests are welcome :)