promotional bannermobile promotional banner

BukkitCLI

BukkitCLI provides a simple way for plugins to execute commands on the command line and can be used as API.

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);
        }
      }
    });
  }

}

The BukkitCLI Team

profile avatar
  • 5
    Projects
  • 15.5K
    Downloads

More from _ForgeUser10659865View all

  • Easy Plant project image

    Easy Plant

    • 4.4K
    • Bukkit Plugins

    Plant seeds, potatos, carrots and more on a whole field by just on click.

    • 4.4K
    • December 30, 2015
    • Bukkit Plugins
  • OpenCTF project image

    OpenCTF

    • 7.0K
    • Bukkit Plugins

    Open world "Capture The Flag". No prebuilt maps. Use all features of Minecraft. Choose an area, build your base and play.

    • 7.0K
    • August 3, 2014
    • Bukkit Plugins
    • +1
  • ServerMonitor project image

    ServerMonitor

    • 1.5K
    • Bukkit Plugins

    Get email notifications for defined log messages.

    • 1.5K
    • October 14, 2013
    • Bukkit Plugins
  • Easy Path project image

    Easy Path

    • 1.7K
    • Bukkit Plugins

    Find your way out of dark caves.

    • 1.7K
    • July 4, 2013
    • Bukkit Plugins
  • Easy Plant project image

    Easy Plant

    • 4.4K
    • Bukkit Plugins

    Plant seeds, potatos, carrots and more on a whole field by just on click.

    • 4.4K
    • December 30, 2015
    • Bukkit Plugins
  • OpenCTF project image

    OpenCTF

    • 7.0K
    • Bukkit Plugins

    Open world "Capture The Flag". No prebuilt maps. Use all features of Minecraft. Choose an area, build your base and play.

    • 7.0K
    • August 3, 2014
    • Bukkit Plugins
    • +1
  • ServerMonitor project image

    ServerMonitor

    • 1.5K
    • Bukkit Plugins

    Get email notifications for defined log messages.

    • 1.5K
    • October 14, 2013
    • Bukkit Plugins
  • Easy Path project image

    Easy Path

    • 1.7K
    • Bukkit Plugins

    Find your way out of dark caves.

    • 1.7K
    • July 4, 2013
    • Bukkit Plugins