Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/lDEVinux/eaglercraft/llms.txt

Use this file to discover all available pages before exploring further.

EaglercraftBungee adds two new events to the standard BungeeCord event system. Register them with the standard @EventHandler annotation in a Listener class, exactly as you would any BungeeCord event. See Plugin Development for how to set up a listener.

Eaglercraft-Specific Events

WebsocketMOTDEvent

net/md_5/bungee/api/event/WebsocketMOTDEvent.java
package net.md_5.bungee.api.event;

import net.md_5.bungee.api.MOTD;

public class WebsocketMOTDEvent extends WebsocketQueryEvent {

    public WebsocketMOTDEvent(MOTD connection) {
        super(connection);
    }

    public MOTD getMOTD() {
        return (MOTD) connection;
    }
}
Triggered when a client or website requests the server’s MOTD (the server list ping). Use getMOTD() to access and modify the MOTD object before it is sent back to the requester. The MOTD interface (which extends QueryConnection) exposes the following methods:
MethodDescription
getLine1() / setLine1(String)First line of the MOTD text
getLine2() / setLine2(String)Second line of the MOTD text
getOnlinePlayers() / setOnlinePlayers(int)Current online player count
getMaxPlayers() / setMaxPlayers(int)Maximum player count
getPlayerList() / setPlayerList(List<String>)Hover player list
getBitmap() / setBitmap(int[])Raw server icon bitmap
getSubType()The sub-type string for this MOTD request
sendToUser()Dispatch the (potentially modified) MOTD to the requester
Example handler:
@EventHandler
public void onMOTD(WebsocketMOTDEvent event) {
    MOTD motd = event.getMOTD();
    // Customise the MOTD lines
    motd.setLine1("&6My Eaglercraft Server");
    motd.setLine2("&aPlayers online: " + motd.getOnlinePlayers());
    // Log the requester's IP
    plugin.getLogger().info("MOTD requested from: " + event.getRemoteAddress());
}
For an animated MOTD and icon, install EaglerMOTD, the official reference plugin that uses this event.

WebsocketQueryEvent

net/md_5/bungee/api/event/WebsocketQueryEvent.java
package net.md_5.bungee.api.event;

import java.net.InetAddress;
import net.md_5.bungee.api.QueryConnection;
import net.md_5.bungee.api.config.ListenerInfo;
import net.md_5.bungee.api.plugin.Event;

public class WebsocketQueryEvent extends Event {

    protected final QueryConnection connection;

    public WebsocketQueryEvent(QueryConnection connection) {
        this.connection = connection;
    }

    public InetAddress getRemoteAddress() {
        return connection.getRemoteAddress();
    }

    public ListenerInfo getListener() {
        return connection.getListener();
    }

    public String getAccept() {
        return connection.getAccept();
    }

    public QueryConnection getQuery() {
        return connection;
    }
}
Triggered when a client or website sends a custom query via a text WebSocket connection. The client opens a WebSocket to the listener and sends a single string of the form Accept: <query>. Use getAccept() to read the query string and getQuery() to obtain the full QueryConnection object for reading request data and writing a response. The QueryConnection interface provides:
MethodDescription
getRemoteAddress()IP address of the connecting client
getListener()The ListenerInfo that received the connection
getAccept()The query string sent by the client (Accept: <value>)
availableRequests()Number of additional request packets available to read
readRequestString()Read the next request payload as a raw string
readRequestData()Read the next request payload as a JSONObject
setReturnType(String) / getReturnType()Set or get the type field in the response envelope
writeResponse(JSONObject)Send a JSON response wrapped in the standard envelope
writeResponse(String)Send a string response wrapped in the standard envelope
writeResponseRaw(String)Send a raw string response with no envelope
writeResponseBinary(byte[])Send a raw binary response
keepAlive(boolean) / shouldKeepAlive()Control whether the connection stays open after a response
isClosed()Check if the connection has been closed
close()Close the connection
Example handler:
@EventHandler
public void onQuery(WebsocketQueryEvent event) {
    if ("players".equals(event.getAccept())) {
        // Respond with current player count
        QueryConnection query = event.getQuery();
        JSONObject data = new JSONObject();
        data.put("count", getProxy().getOnlineCount());
        query.writeResponse(data);
        plugin.getLogger().info("Player count query from " + event.getRemoteAddress());
    }
}
WebsocketMOTDEvent extends WebsocketQueryEvent, so you can handle both with a single WebsocketQueryEvent listener if needed. Use instanceof WebsocketMOTDEvent to branch on MOTD requests specifically.

Standard BungeeCord Events

All standard BungeeCord events are available in EaglercraftBungee without modification. The most commonly used ones are listed below.
EventTrigger
LoginEventA player is attempting to connect. Cancellable — use setCancelled(true) and setCancelReason(String) to reject the connection.
PostLoginEventA player has successfully logged in and is now fully connected. Use getPlayer() to get the ProxiedPlayer.
PlayerDisconnectEventA player has disconnected. Use getPlayer() to get the ProxiedPlayer.
ChatEventA player sends a chat message or command. Cancellable. Use getMessage() / setMessage(String) to read or modify the text, and isCommand() to detect commands.
ServerConnectEventA player is about to connect to a backend server.
ServerConnectedEventA player has successfully connected to a backend server.
ServerKickEventA player was kicked from a backend server.
ServerSwitchEventA player switched between backend servers.
PluginMessageEventA plugin message was received on a registered channel.
ProxyPingEventThe proxy was pinged (standard TCP ping, distinct from WebsocketMOTDEvent).
PermissionCheckEventA permission check was triggered for a player or connection.
Example — cancelling a login:
@EventHandler
public void onLogin(LoginEvent event) {
    if (isBanned(event.getConnection().getName())) {
        event.setCancelled(true);
        event.setCancelReason("You are banned from this server.");
    }
}

Build docs developers (and LLMs) love