Lesson 10 of 13 · 18m
Plugin Messaging: Talking Through the Proxy
bungeecord:main channels, Connect payloads, and the forwarding secret that keeps rogue proxies out of your backend.
Most production servers are not one server. Behind Velocity or BungeeCord sit a lobby, three minigame instances, and a survival world, and the day your plugin needs "send this player to lobby" or "sync this ban across the network," you meet the plugin messaging API — custom payloads multiplexed onto the player's existing connection.
The mechanism
A client connects to the proxy; the proxy connects to a backend. Plugin messages are packets carried inside that connection, addressed by channel name. You do not open sockets, and you cannot send without a player — messages ride piggybacked on a live session. Zero players online means zero channels to write on.
// onEnable
getServer().getMessenger()
.registerOutgoingPluginChannel(this, "bungeecord:main");
getServer().getMessenger()
.registerIncomingPluginChannel(this, "bungeecord:main", new BungeeListener());bungeecord:main is the modern channel name every proxy speaks; legacy BungeeCord also answers on "BungeeCord". Moving a player:
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("Connect");
out.writeUTF("lobby");
player.sendPluginMessage(plugin, "bungeecord:main", out.toByteArray());Player.sendPluginMessage — always through a Player, the conduit. Subchannels worth knowing: Connect moves a player, GetServer asks which backend you sit on, PlayerCount sizes a remote server, Forward delivers a payload to other backends. Forward payloads carry their own sub-format — target (ALL/ONLINE/a server name), the subchannel name, then a length-prefixed byte array — read the Spigot docs once and copy the layout exactly; the field order is load-bearing.
Replies arrive in a PluginMessageListener#onPluginMessageReceived implementation, read back with ByteArrayDataInput in the same field order you wrote them:
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String sub = in.readUTF(); // "GetServer"
String name = in.readUTF(); // the backend's name
}ByteArrayDataOutput and ByteStreams come from Guava, which the server already ships — compileOnly territory, no shading needed. The zero-player edge case has a real pattern: queue outbound messages until PlayerJoinEvent hands you a conduit, then flush.
The custom-channel path — your own namespace:channel like sudotools:bansync — is how two backends share plugin state without the proxy's reserved vocabulary. Register it on both ends, keep payloads small, and version the first byte; the day you change the wire format, old backends must not read it as garbage.
Worth noting: plugin messages are not guaranteed delivery. A disconnect mid-send drops the payload, and the proxy won't retry. Anything that must land — a ban, a purchase — needs an acknowledgement on the return channel or a shared database as the source of truth.
The security boundary nobody configures
Plugin messaging only works because the backend trusts the proxy, and that trust is configuration, not magic. Backend servers behind a proxy run online-mode=false: they accept whatever UUID and username the proxy asserts. A rogue proxy pointed at your backend's public port can claim to be Notch — or any admin with * permissions.
Two fixes, both real:
- Velocity modern forwarding: a shared secret in
config/paper-global.ymlunderproxies.velocity.secret, matched to the proxy'sforwarding.secret. A proxy that cannot prove the secret gets its forwarded data rejected. This is the one to use. - BungeeGuard or a strict IP allowlist for legacy BungeeCord setups — weaker, but the alternative is a public offline-mode server, which is not a server; it is a door.
Firewall the backend port to the proxy host regardless. The forwarding secret is the second layer, not the first.
Field notes
- Register channels in
onEnable; unregistered sends throw. - Plugin messages are small — kilobytes, not files. Bulk sync between backends goes over HTTP on a private port.
- Velocity also supports custom
namespace:channelmessaging for plugin-to-plugin traffic across the proxy — the cleaner path when you own both ends.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Bukkit, Spigot, Paper, Folia: What You're Actually Running
There is a fifteen-year fork tree underneath every Minecraft server, and most admins copy a jar without knowing what's in it. Here's the whole chain, with the code — including the config key most DAB guides get wrong.
A Minecraft Mod Is a Program. In 2026, Attackers Started Acting Like It.
A Minecraft mod is a Java program that runs with your account's full permissions, and nothing in the game checks what it does.
Minecraft 26.3 Turned the Whitelist On. Your Server Probably Didn't Notice.
A fresh Minecraft 26.3 server now ships with white-list=true, so new servers are closed to strangers from the first start. Existing servers that upgraded kept their old value, which for most of them means still open.
Your Minecraft Server Isn't Slow, It's Misconfigured
Can't keep up! is not a hardware message. It's the server telling you a tick took longer than 50ms, and almost every cause is a default nobody changed. Here's what actually moves MSPT, with the flags that are now wrong and the setting that isn't where every guide says it is.