Skip to content

Plugin API

JonathanxD edited this page Mar 1, 2017 · 4 revisions

Sandstone tries to provide a Sponge-Bukkit-like API, the Sandstone API is very similar to Sponge API and bit similar to Bukkit API.

Creating a Plugin

Sandstone plugin class is very similar to Sponge plugin class. We use Google Guice to Inject dependencies in the code.

Provided Dependencies

By default Sanstone provides following dependencies:

  • Game
  • Platform
  • EventManager
  • PluginManager
  • ServiceManager
  • PluginContainer (of the plugin)
  • PluginDefinition: (of the plugin)
    • Changes in their values is reflected in the PluginContainer (don't work after instance initialization, and don't work in Scala and Kotlin object).
  • Logger (of the plugin)
  • PluginContainer of others plugins, plugin id should be provided in @com.google.inject.name.Named annotation.

Main class

import com.google.inject.Inject;

import com.github.projectsandstone.api.Game;
import com.github.projectsandstone.api.logging.Logger;
import com.github.projectsandstone.api.plugin.Plugin;

@Plugin(id = "com.mypackage.myplugin", version = "1.0")
public class MyPlugin {
    
    private final Game game;
    private final Logger logger; // Attention here, import Sandstone Logger class, not Java Logger class.
    
    @Inject
    public MyPlugin(Game game, Logger logger) {
        this.game = game;
        this.logger = logger;
    }
    
}
Clone this wiki locally