Cluster (network state)
What the servers of a minigame network know about each other: every server's arenas and the players on their way to one, over MySQL / MariaDB or Redis. Game servers write their arenas; hubs, proxies and other game servers read them. SurvivalGames and its hub plugin are built on it.
| Part | Does |
|---|---|
| Arenas | Each game server publishes its arenas every few seconds; an arena not refreshed for 15 s is gone |
| Joins | A sender writes "this player goes to that arena", then moves the player; the game server takes them in |
| Seats | reserve checks the arena's free places and writes the join in one atomic step |
| Quick Join | The fullest joinable arena, the one starting soonest |
| Locks | Network-wide locks with expiry (e.g. one server editing a map) |
java
Cluster cluster = Cluster.connect(settings, getLogger()); // MySQL or Redis, from ClusterSettings
cluster.publish("sg-1", arenas); // a game server, every few seconds
cluster.arenas().thenAccept(all -> updateMenu(all)); // a hub
cluster.reserve(player, "sg-1", "breeze").thenAccept(ok -> { // a seat, then send the player
if (ok) connect(player, "sg-1");
});Every call returns a CompletableFuture; nothing blocks the main thread.
- MySQL: two tables, polled every couple of seconds.
- Redis: a hash per server with a TTL, a key per traveling player, pub/sub so menus update at once.
Cluster isn't part of the EranoAPI plugin: shade it into your plugin and relocate me.erano.com.api.cluster, Jedis, HikariCP and the MariaDB driver. See the Cluster README.