Skip to Content
MineDuels

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

  1. Copy MineDuels-Velocity-<version>.jar into the proxy plugins/ folder.
  2. Start the proxy once. It writes plugins/mineduels/config.properties.
  3. 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
KeyDefaultMeaning
proxy-nameproxyThe name of the proxy in /mdproxy. It must differ from every backend name.
redis.host, port, password, databaselocalhost, 6379, empty, 0The Redis of the backends. The password cannot be empty.
redis.sslfalseUse TLS to Redis.
secretemptyThe same secret as cross-server.secret on the backends.
balance-first-jointrueSend a player who connects to the least full lobby. See below.
public-addressemptyThis proxy's address (host:port) for players moved here from another proxy. See Regions.
accepts-transfersfalseSet to true when velocity.toml has accepts-transfers = true and public-address is set.
regionemptyOptional. The region of this proxy (for example eu); empty means no regions. Backends behind it are in this region. See Regions.
region-displayemptyThe name players see in /regions.
latency.<region>100Estimated milliseconds from this region to another one, for example latency.sg=170.
config-version2Written by the plugin. Do not change it.
gate.*, drain.no-alternativesee the gateWhich players may connect to game servers, and what a draining lobby does.
max-message-bytes, window-seconds, nonce-capacity65536, 30, 50000The message protection values. Use the same values as the backends.
limits.pre-auth, limits.heartbeat, limits.chat, limits.other2000, 5, 20, 100Messages 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,Bob

The 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

TaskBehaviour
TransfersWhen 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 connectionWith 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 choiceThe least full lobby is chosen from the heartbeats of the lobbies, not full ones first.
HeartbeatThe proxy publishes its own heartbeat every 2 seconds so the backends can see it.
Game server gateOnly players of a match, spectators and players with mineduels.proxy.bypass may connect to a game server. See Restarts and the game server gate.
DrainDraining backends are skipped when a lobby is chosen. /mdproxy drain stops new logins on the proxy itself.
Webhookplugins/mineduels/webhook.yml posts when the proxy or the network is empty. See Webhooks.

Commands

CommandPermissionPurpose
/lobby, /hubnoneSends the player to the least full lobby.
/mdproxymineduels.proxy.adminLists 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, statusmineduels.proxy.adminStops new logins and transfers to this proxy. Players already connected stay.
/mdproxy reloadmineduels.proxy.adminReads the gate.* keys, balance-first-join and webhook.yml again.

Examples:

/mdproxy
/mdproxy drain start restart tonight
/mdproxy drain status
/mdproxy reload

Sample /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 ago

Server 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: practice

The 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.

On this page