Skip to content

Developer API

Moros edited this page Oct 28, 2024 · 17 revisions

Adding Bending to your project

The API artifact is published to the Maven Central repository:

Maven Central

Maven

  <repositories>
    <repository>
        <id>sonatype-oss-snapshots</id>
        <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
    </repository>
  </repositories>

 <dependency>
    <groupId>me.moros</groupId>
    <artifactId>bending-api</artifactId>
    <version>3.10.0</version>
    <scope>provided</scope>
</dependency>

Gradle (Kotlin)

repositories {
    mavenCentral()
    maven("https://oss.sonatype.org/content/repositories/snapshots/") // For snapshots
}

dependencies {
    compileOnly("me.moros:bending-api:3.10.0")
}

Obtaining an instance of the API

Javadocs

The root API interface is Game.

Bukkit

You can obtain it using the Bukkit ServicesManager

RegisteredServiceProvider<Game> provider = Bukkit.getServicesManager().getRegistration(Game.class);
if (provider != null) {
  Game game = provider.getProvider();
  // Do stuff with it
}

Sponge

ServiceRegistration<Game> provider = Sponge.game().serviceProvider().registration(Game.class).orElse(null);
if (provider != null) {
  Game game = provider.service();
  // Do stuff with it
}

All platforms

An instance of Game can also be obtained from the GameProvider class.

Game game = GameProvider.get(); // Throws IllegalStateException if Game isn't loaded

You can also check the addon system.