Proxy server
Proxy and ProxyServer are the same v3 constructor.
const { Proxy, ProxyServer } = require("JNbot");
const proxy = new Proxy({
proxyPort: 25565,
host: "play.example.net",
port: 25565,
});
Configuration
proxyPort is the local port Minecraft clients connect to. host and port select the upstream server. They default to the active JNbot server profile.
type ProxyServerConfig = {
proxyPort?: number;
host?: string;
port?: number;
fallbackVersion?: string;
};
fallbackVersion only controls server-list ping data when JNbot cannot identify a protocol. A real client connection always uses the version from its handshake.
Connections
proxy.on("connection", (connection) => {
console.log(connection.username);
console.log(connection.uuid);
console.log(connection.isReady);
});
proxy.on("disconnection", (connection) => {
console.log(`${connection.username} disconnected`);
});
Use getUser(username) for one active connection. getProxies() returns all active connections by username. getActiveUsers() returns lightweight data for the proxy UI.
const connection = proxy.getUser("Player");
if (connection) {
connection.end("Maintenance");
}
proxy.kick("Player", "Maintenance");
proxy.stop();
Recorder events
The proxy forwards recorder lifecycle events.
proxy.on("recorder:start", (recorder) => {
console.log(recorder.id);
});
proxy.on("replay:stop", (replay) => {
console.log(replay.filename);
});
The proxy handles handshakes, login, status requests, and authentication itself. Packet handlers begin once JNbot relays traffic between the connected player and upstream server.