Skip to main content

Getting Started with the API

Improved Factions provides a lightweight API that can be used by external plugins to interact with its core functionality.

Note: If a specific feature isn’t available through the public API yet, you can still access most internals by retrieving the plugin instance via the server’s plugin manager. Almost all functionality is accessible this way.

The plugin is written in Kotlin, and it is recommended to use Kotlin when integrating. However, Java is also supported. Be aware that some method or class names may differ slightly due to how Kotlin compiles to Java bytecode. Still, the exposed API objects remain consistent across both languages.

JitPack Integration

The plugin is published on JitPack, making it easy to include in your Gradle project.

Add the following to your build.gradle.kts:

repositories {
maven("https://jitpack.io")
}

dependencies {
implementation("com.github.ToberoCat:ImprovedFactions:<version>")
}

Replace <version> with the desired release tag or commit hash (e.g., 2.3.0-dev). You can find available versions on the JitPack project page.

Working with the underlying api

When you access any faction fucntions not wrapped by the api wrappers, you are almost certainly going to need a transaction for all actiosn that affect database modifications.

Transactions are handled by jetbrains exposed. Here is how one can access them:

val faction = ImprovedFactionsAPI.getFaction("Knights") // Transactions handled by the api wrapper
transaction {
faction.join(player.uniqueId, 1) // This is a none api wrapped function, joining a player, therefore one needs to provide transaction
}

For java usage, one has to check jetbrains exposed documentation

Further docs

Browse full API documentation

Get help

For support, visit the Improved Factions Discord or open an issue on GitHub.