Back to homepage

The Server Assistant API


You can find the Javadocs for the API here. If you know what you are doing, the Javadocs should be all you need to help you program.

Basic Tutorial

Adding ServerAssistant as a dependency to your plugin:

  1. In your plugin.yml you will need to add ServerAssistant as a dependency. After, your plugin.yml should look something like this:

    name: <Plugin Name>
    author: '<Your Name>'
    main: <PluginMainClass>
    version: <Version>
    depend: [ServerAssistant]

    This now means that your plugin will load after Server Assistant.

  2. You will next need to add the 'ServerAssistant.jar' as a compile time dependency in your IDE/Dependency Management system.

    With gradle:

    1. Since Server Assistant isn't in a maven repository, you'll need to tell gradle to look for dependencies in the filesystem. Add the following to your gradle script:

      repositories {
      	flatDir {
      	   dirs 'C:/ServerAssistant/'

      Make sure that the directory you specify (Eg. C:/ServerAssistant/) isn't part of the your code repository. You may not include ServerAssistant in any public code or maven repository.

    2. Next, place your downloaded ServerAssistant JAR into the directory you specified in the script. The jar should be named something like 'ServerAssistant-1.0.jar'.

    3. Finally, you will need to add the following to your gradle script

      dependencies {
          compile name: 'ServerAssistant-1.0'

      Make sure that the name specified matches the name of your ServerAssistant JAR

    With eclipse:

    1. Right click on your project and then click on properties.
    2. Open the 'Java Build Path' page, go to the 'Libraries' tab and click 'Add External JARs'
    3. Navigate to where your JAR is located, select it and then press 'Open'. Make sure the JAR isn't included in your code repository. You may not include ServerAssistant in any public code or maven repository.
    4. Press the 'Ok' button to finish.

Getting an instance of the API:

ServerMonitorAPI api = ServerMonitorAPIProvider.getAPI();

Once you have an instance of the API, you can use the javadocs to find out what you are able to do.
For example, if you want to broadcast a message to the server when it is lagging:

On enable:
api.getResponseManager().addResponder(new LagBroadcastResponder());
LagBroadcastResponder class:
public class LagBroadcastResponder implements Responder {

	public ServerEventType[] getListenedEvents() {
		return new ServerEventType[]{ServerEventType.LAG};

	public void respond(ServerEvent event) {
		LagReport report = (LagReport) event.getReport();
		Bukkit.broadcastMessage("The server is lagging! TPS is "+report.getTps());