Skip to main content
Use a server event when your plugin needs to continue work as soon as a server becomes available. For example, a matchmaking or routing system can resume requests that were waiting for a server to start.

Listen for available servers

The listener uses the CloudApi client your plugin already owns and notifies your application code when a server becomes available:
ServerAvailabilityListener.java
Create the listener when your plugin starts and connect it to the work that is waiting for an available server:
Treat the callback as a signal to retry waiting work or refresh the destinations known to your routing system.
Events only report changes that happen after you subscribe. If your plugin also needs the current state when it starts, load it separately through the Servers API.
If the callback changes Bukkit, Folia, Velocity, or BungeeCord state, schedule that platform-specific work through the platform’s scheduler.

Close the listener

Close the listener when your plugin stops, before closing the shared CloudApi client:
This stops future callbacks. The listener does not close the shared CloudApi client. See the Events API reference for the other event categories and callback types.