The following guide will show you how to implement our API in your Paper plugin.
Our API includes the ControllerApi and the PlayerApi class. The ControllerApi is used to interact with SimpleCloud’s groups, servers, and more, while the PlayerApi is used to interact with players.
Dependencies
While we are working on a native Paper implementation, you can use our Spigot API for now.
First, we need to add the dependencies to your build.gradle or pom.xml:
Gradle (Kotlin)
Gradle (Groovy)
Maven
repositories {
maven("https://repo.simplecloud.app/snapshots")
maven("https://buf.build/gen/maven")
maven("https://repo.papermc.io/repository/maven-public/")
}
dependencies {
compileOnly("app.simplecloud.api.platform:spigot:LATEST")
compileOnly("io.papermc.paper:paper-api:1.21.5-R0.1-SNAPSHOT")
}
repositories {
maven { url 'https://repo.simplecloud.app/snapshots' }
maven { url 'https://buf.build/gen/maven' }
maven { url 'https://repo.papermc.io/repository/maven-public/' }
}
dependencies {
compileOnly 'app.simplecloud.api.platform:spigot:LATEST'
compileOnly 'io.papermc.paper:paper-api:1.21.5-R0.1-SNAPSHOT'
}
<repositories>
<repository>
<id>simplecloud-snapshots</id>
<url>https://repo.simplecloud.app/snapshots</url>
</repository>
<repository>
<id>buf-maven</id>
<url>https://buf.build/gen/maven</url>
</repository>
<repository>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>app.simplecloud.api.platform</groupId>
<artifactId>spigot</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
Please don’t compile our API into your plugin, just follow the next step, and
depend on the API.
Depend on the API
Paper plugins can inherit from the SimpleCloud Cloud API plugin. This is useful if you want to use the SimpleCloud API in your plugin.
For this, you need to add a depend configuration to your plugin.yml file. Here is an example:
name: simplecloud-example-paper
version: 1.0.0
main: app.simplecloud.examples.plugin.paper.PaperExamplePlugin
depend: [simplecloud-api]
After that, you can use the SimpleCloud API in your plugin:
import app.simplecloud.controller.api.ControllerApi
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import org.bukkit.plugin.java.JavaPlugin
class PaperExamplePlugin : JavaPlugin() {
private val controllerApi = ControllerApi.createCoroutineApi()
override fun onEnable() {
logger.info("Hello from Paper!")
CoroutineScope(Dispatchers.IO).launch {
val groups = controllerApi.getGroups().getAllGroups()
logger.info("Groups: $groups")
}
}
}
import app.simplecloud.controller.api.ControllerApi;
import org.bukkit.plugin.java.JavaPlugin;
public class PaperExamplePlugin extends JavaPlugin {
private final ControllerApi.Future controllerApi = ControllerApi.createFutureApi();
@Override
public void onEnable() {
getLogger().info("Hello from Paper!");
controllerApi.getGroups().getAllGroups().thenAccept(groups -> {
getLogger().info("Groups: " + groups);
});
}
}