Velocity plugin
Install MineDuels-Velocity on the proxy and configure plugins/mineduels/config.properties.
The proxy plugin moves players between backends when a server asks for it, and balances players over the lobbies. It uses the same Redis and secret as the backends. Update the proxy and the backends together.
Install
- Copy
MineDuels-Velocity-<version>.jarinto the proxyplugins/folder. - Start the proxy once. It writes
plugins/mineduels/config.properties. - Fill in the file below and restart the proxy.
The names under [servers] in velocity.toml should be the cross-server.server-name of the backends, spelled exactly the same. When they differ, set cross-server.proxy-server-name in the backend's database.yml (see below):
[servers]
lobby-1 = "10.0.0.10:25565"
game-1 = "10.0.0.11:25565"config.properties
proxy-name=proxy
redis.host=redis.internal
redis.port=6379
redis.password=change-this
redis.database=0
redis.ssl=false
secret=paste the shared secret here
balance-first-join=true| Key | Default | Meaning |
|---|---|---|
proxy-name | proxy | The name of the proxy in /mdproxy. It must differ from every backend name. |
redis.host, port, password, database | localhost, 6379, empty, 0 | The Redis of the backends. The password cannot be empty. |
redis.ssl | false | Use TLS to Redis. |
secret | empty | The same secret as cross-server.secret on the backends. |
balance-first-join | true | Send a player who connects to the least full lobby. See below. |
public-address | empty | This proxy's address (host:port) for players moved here from another proxy. See Regions. |
accepts-transfers | false | Set to true when velocity.toml has accepts-transfers = true and public-address is set. |
region | empty | Optional. The region of this proxy (for example eu); empty means no regions. Backends behind it are in this region. See Regions. |
region-display | empty | The name players see in /regions. |
latency.<region> | 100 | Estimated milliseconds from this region to another one, for example latency.sg=170. |
config-version | 2 | Written by the plugin. Do not change it. |
gate.*, drain.no-alternative | see the gate | Which players may connect to game servers, and what a draining lobby does. |
max-message-bytes, window-seconds, nonce-capacity | 65536, 30, 50000 | The message protection values. Use the same values as the backends. |
limits.pre-auth, limits.heartbeat, limits.chat, limits.other | 2000, 5, 20, 100 | Messages per second accepted. |
Example for a proxy in region eu that gates two extra servers and trusts two names without a permissions plugin:
proxy-name=proxy-eu
region=eu
gate.extra-servers=practice,event-hub
gate.bypass-players=Alice,BobThe proxy stays off, and logs the reason, while redis.password is empty or secret is shorter than 32 bytes. A wrong proxy-name, public-address, region or latency.* only logs a warning and the setting is skipped.
What the proxy does
| Task | Behaviour |
|---|---|
| Transfers | When a backend publishes a transfer, the proxy connects the listed players to the target server. An empty or unknown target means the least full lobby. |
| First connection | With balance-first-join, a player whose server Velocity chose is a known lobby is sent to the least full lobby instead. A forced host, a duel server or a time before any lobby has been heard from leave Velocity's choice alone. |
| Lobby choice | The least full lobby is chosen from the heartbeats of the lobbies, not full ones first. |
| Heartbeat | The proxy publishes its own heartbeat every 2 seconds so the backends can see it. |
| Game server gate | Only players of a match, spectators and players with mineduels.proxy.bypass may connect to a game server. See Restarts and the game server gate. |
| Drain | Draining backends are skipped when a lobby is chosen. /mdproxy drain stops new logins on the proxy itself. |
| Webhook | plugins/mineduels/webhook.yml posts when the proxy or the network is empty. See Webhooks. |
Commands
| Command | Permission | Purpose |
|---|---|---|
/lobby, /hub | none | Sends the player to the least full lobby. |
/mdproxy | mineduels.proxy.admin | Lists every server of the network with its role, players, free arenas and the age of its last heartbeat. A stale server is shown dimmed. A draining server shows [draining]. |
/mdproxy drain start [reason], stop, status | mineduels.proxy.admin | Stops new logins and transfers to this proxy. Players already connected stay. |
/mdproxy reload | mineduels.proxy.admin | Reads the gate.* keys, balance-first-join and webhook.yml again. |
Examples:
/mdproxy
/mdproxy drain start restart tonight
/mdproxy drain status
/mdproxy reloadSample /mdproxy output:
MineDuels network (proxy-eu, Redis on):
lobby-1 lobby 12/100 players 2s ago
lobby-2 lobby 3/100 players [draining] 1s ago
game-1 game 8/50 players 2 free arenas 1s agoServer names that differ
A backend says its own name under [servers] in velocity.toml. Set cross-server.proxy-server-name in its database.yml:
# on the duel server whose velocity.toml name is practice
cross-server:
server-name: game-1
proxy-server-name: practiceThe name travels in the backend's heartbeat through Redis, so the proxy needs no list of its own. It is used for transfers, for choosing the least full lobby and for sending a returning player back to their match. A backend whose name is not in velocity.toml is reported once every 10 minutes in the proxy log, and /mdproxy marks it [not in velocity.toml]. With an empty proxy-server-name the backend's server-name is used.
Where a joining player goes
The proxy does not rely on Velocity's try list when it knows better. For every join it first looks in Redis for a held place: a duel server keeps one for a player who disconnected after a match was found, for disconnect-grace-seconds. If there is one, the player goes straight to that duel server. Otherwise a first connection goes to the least full lobby (balance-first-join), whatever the try list in velocity.toml says. The only exception is a forced host: a player who connects through an address listed under [forced-hosts] stays on the server that address names. Velocity's own try list is only used when no lobby has been heard from yet.
The lookup runs away from the network thread and waits at most about 250 ms. If Redis is slow or down, the player joins normally and lookups pause for 10 seconds after repeated failures. The held place is signed with the shared secret and can be used once.