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

Controller API

Groups API

Managing groups with the SimpleCloud Controller API

Initialization

Before you can use the Groups API, you need to initialize the Controller API. Please refer to the Initialization guide for more information.

After initializing the Controller API, you can use controllerApi.getGroups() to access the Groups API.

Create Group

Creating groups is very simple. You can create a group with the createGroup method.

val group = Group(
    name = "lobby",
    type = ServerType.SERVER,
    minMemory = 512,
    maxMemory = 1024,
    startPort = 25565,
    minOnlineCount = 1,
    maxOnlineCount = 5,
    maxPlayers = 100,
    newServerPlayerRatio = 50,
    properties = mapOf("gamemode" to "LOBBY")
)
 
val createdGroup = controllerApi.getGroups().createGroup(group)

Get Groups

We provide multiple ways to get groups. You can get a specific group by name, all groups, or groups by type.

// Get a specific group
val lobbyGroup = controllerApi.getGroups().getGroupByName("lobby")
 
// Get all groups
val allGroups = controllerApi.getGroups().getAllGroups()
 
// Get groups by type
val serverGroups = controllerApi.getGroups().getGroupsByType(ServerType.SERVER)

Update & Delete Groups

Updating and deleting groups is also very simple. You can update a group with the updateGroup method and delete a group with the deleteGroup method.

// Update a group
val updatedGroup = existingGroup.copy(
    maxPlayers = 200,
    maxMemory = 2048
)
controllerApi.getGroups().updateGroup(updatedGroup)
 
// Delete a group
controllerApi.getGroups().deleteGroup("lobby")

On this page