Skip to main content

Overview

ECServerAPI is the primary entry point for the Ember Client Server API. It extends JavaPlugin and provides methods to send packets to players using the Ember client and check their connection status.

Class Definition

public final class ECServerAPI extends JavaPlugin

Getting the Instance

getInstance()

Returns the singleton instance of the API.
public static ECServerAPI getInstance()
return
ECServerAPI
The singleton instance of ECServerAPI
Example:
ECServerAPI api = ECServerAPI.getInstance();

Constants

CHANNEL_NAME

The plugin messaging channel name used for communication.
public static final String CHANNEL_NAME = "ember:data"
CHANNEL_NAME
String
The channel identifier: "ember:data"

Methods

sendPacket()

Sends a packet to a player if they are connected using the Ember client.
public void sendPacket(Player player, Packet packet)
player
Player
required
The Bukkit player to send the packet to
packet
Packet
required
The packet to send
Example:
ECServerAPI api = ECServerAPI.getInstance();
Player player = // ... get player

// Request attestation registration
api.sendPacket(player, new OutAttestationRegister());
This method automatically checks if the player is using the Ember client. If they are not, the packet is silently ignored.

isPlayerOnEmber()

Checks whether a player is connected using the Ember client.
public boolean isPlayerOnEmber(UUID uuid)
uuid
UUID
required
The unique identifier of the player to check
return
boolean
true if the player is using Ember client, false otherwise
Example:
ECServerAPI api = ECServerAPI.getInstance();
Player player = // ... get player

if (api.isPlayerOnEmber(player.getUniqueId())) {
    // Player is using Ember client
    api.sendPacket(player, new OutAttestationRegister());
} else {
    // Player is using vanilla client
    player.sendMessage("You need the Ember client to use this feature.");
}

getPacketManager()

Returns the packet manager for advanced packet handling.
public PacketManager getPacketManager()
return
PacketManager
The PacketManager instance handling packet serialization and registration
Example:
ECServerAPI api = ECServerAPI.getInstance();
PacketManager packetManager = api.getPacketManager();
Most users will not need to interact with the PacketManager directly. Use sendPacket() for sending packets.

Complete Example

import com.emberclient.serverapi.ECServerAPI;
import com.emberclient.serverapi.packet.impl.attestation.register.OutAttestationRegister;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;

public class MyPlugin implements Listener {
    
    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent event) {
        Player player = event.getPlayer();
        ECServerAPI api = ECServerAPI.getInstance();
        
        // Check if player is using Ember
        if (api.isPlayerOnEmber(player.getUniqueId())) {
            // Request attestation registration
            api.sendPacket(player, new OutAttestationRegister());
        }
    }
}

Build docs developers (and LLMs) love