Thanks to visit codestin.com
Credit goes to docs.simplecloud.app

Developer Guide/Getting Started

Start with Velocity

Implementing the SimpleCloud Controller API in Velocity

The following guide will show you how to implement our API in your Velocity plugin.

Our API includes the ControllerApi and the PlayerApi class. The ControllerApi is used to interact with the SimpleCloud's groups, servers, and more, while the PlayerApi is used to interact with players.

Dependencies

First, we need to add the dependencies to your build.gradle or pom.xml:

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:velocity:latest")
    compileOnly("com.velocitypowered:velocity-api:3.4.0-SNAPSHOT")
    annotationProcessor("com.velocitypowered:velocity-api:3.4.0-SNAPSHOT") 
    // Use kapt if you're using Kotlin
    kapt("com.velocitypowered:velocity-api:3.4.0-SNAPSHOT")
}

Depend on the API

Velocity plugins can inherit from the SimpleCloud Cloud API plugin. This is useful if you want to use the SimpleCloud API in your plugin.

import app.simplecloud.controller.api.ControllerApi
import com.velocitypowered.api.event.Subscribe
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent
import com.velocitypowered.api.plugin.Dependency
import com.velocitypowered.api.plugin.Plugin
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
 
@Plugin(
    id = "simplecloud-example-velocity",
    name = "SimpleCloud Example Velocity Plugin",
    authors = ["Fllip"],
    dependencies = [
        // This is very important, otherwise the API be loaded after your plugin
        Dependency(id = "simplecloud-api")
    ]
)
class VelocityExamplePlugin {
 
    private val logger = org.slf4j.LoggerFactory.getLogger(VelocityExamplePlugin::class.java)
    private val controllerApi = ControllerApi.createCoroutineApi()
 
    @Subscribe
    fun onProxyInitialize(event: ProxyInitializeEvent) {
        logger.info("Hello from Velocity!")
 
        CoroutineScope(Dispatchers.IO).launch {
            val groups = controllerApi.getGroups().getAllGroups()
            logger.info("Groups: $groups")
        }
    }
 
}

On this page