-
Couldn't load subscription status.
- Fork 0
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.
Sandstone plugin class is very similar to Sponge plugin class. We use Google Guice to Inject dependencies in the code.
By default Sanstone provides following dependencies:
GamePlatformEventManagerPluginManagerServiceManager-
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 Kotlinobject).
- Changes in their values is reflected in the
-
Logger(of the plugin) -
PluginContainerof others plugins, plugin id should be provided in@com.google.inject.name.Namedannotation.
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;
}
}