BukkitCLI
With BukkitCLI you can define and execute commands on the servers command line. With a CallbackHandler you can handle possible output. It will work as an API for other plugins to use and may support native ways of command triggering.
You need to be in control of the server minecraft is running on. This plugin wont wont work if you have no rights on the underlying server.
I recommend to group commands into little scripts and execute them instead of complex commands via BukkitCLI. You can run commands through bash but JavaRuntime does not do this by default. See examples for more information.
Links
Use Cases
- Run an external backup script
- Check availability of a service
- Create a control room for your server for fun
Usage
- Include BukkitCLI.jar in your build path
- Import de.wrenchbox.cli.BukkitCLI in your class
- Use one of the BukkitCLI.createJob() methods to schedule a job
Info
- The job manager will queue all jobs and run them one after another according to FIFO principle.
- You can define the working directory of a job
- You can pass a callback handler to handle exit code, output and errors resulting from your command
Road Map
- Native support for defining commands in addition to the API functionality
- Permissions
Examples
package de.wrenchbox.test; import org.bukkit.plugin.java.JavaPlugin; import de.wrenchbox.cli.BukkitCLI; import de.wrenchbox.cli.jobs.CallbackHandler; public class TestPlugin extends JavaPlugin { @Override public void onEnable() { if (!getDataFolder().exists()) { getDataFolder().mkdirs(); } // print the current working directory. should be the server root // [13:24:21 INFO]: [TestPlugin] Current directory: /home/amshaegar/workspace/Minecraft BukkitCLI.createJob("pwd", new CallbackHandler() { @Override public void execute(int exitCode, String out, String err) { getLogger().info(String.format("Current directory: %s", out)); } }); // create a file 'last_run' in the plugin directory // plugins/TestPlugin/last_run BukkitCLI.createJob("touch last_run", getDataFolder()); // print the system date and time // [13:24:21 INFO]: [TestPlugin] System time: So 25. Mai 13:24:21 CEST 2014 BukkitCLI.createJob("date", getDataFolder(), new CallbackHandler() { @Override public void execute(int exitCode, String out, String err) { if (exitCode == 0) { getLogger().info(String.format("System time: %s", out)); } else { getLogger().warning(err); } } }); } }
Comments