Skip to main content
When a player needs a server, query the group for available capacity and connect them to the least-loaded instance.
Let SimpleCloud manage the number of servers in a group. This workflow only chooses from instances that are ready now.

Route a player to a group

The following router finds playable servers in a group, ignores full instances, and attempts one connection. It returns NoCapacity when no suitable server is available and ConnectionAttempted with the result from CloudPlayer.connect otherwise.
GroupRouter.java
AVAILABLE and INGAME servers can accept players. Sorting by player count spreads new connections across the group, while the numerical ID gives the selection a stable tie-breaker. The server name uses SimpleCloud’s default <groupName>-<numericalId> registration pattern, such as lobby-3. If you changed the registration pattern, build the name with that same pattern here. Handle NoCapacity by keeping the player in your queue or fallback lobby. For ConnectionAttempted, use the returned ConnectResult to confirm the connection or show an appropriate fallback.

Next steps

  • Use the Groups API to create and configure groups.
  • Use the event handling guide when your plugin should react as servers become available.
  • See the Servers API for server queries, models, and lifecycle actions.