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.
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.ControllerApiimport com.velocitypowered.api.event.Subscribeimport com.velocitypowered.api.event.proxy.ProxyInitializeEventimport com.velocitypowered.api.plugin.Dependencyimport com.velocitypowered.api.plugin.Pluginimport kotlinx.coroutines.CoroutineScopeimport kotlinx.coroutines.Dispatchersimport 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") } }}