Skip to content

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.

PartDoes
ArenasEach game server publishes its arenas every few seconds; an arena not refreshed for 15 s is gone
JoinsA sender writes "this player goes to that arena", then moves the player; the game server takes them in
Seatsreserve checks the arena's free places and writes the join in one atomic step
Quick JoinThe fullest joinable arena, the one starting soonest
LocksNetwork-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.

SurvivalGames is a paid plugin. EranoAPI is open source under the MIT license.