Apollo
Developers
Events

Events

Overview

Apollo provides its own listener based event system, similar to the existing event system found in Bukkit.

List of available Apollo events

ApolloRegisterPlayerEvent

ApolloRegisterPlayerEvent

Called when the player joins the server using Lunar Client.

FieldDescription
ApolloPlayer playerThe Apollo player that was registered.
ApolloUnregisterPlayerEvent

ApolloUnregisterPlayerEvent

Called when the player leaves the server using Lunar Client.

FieldDescription
ApolloPlayer playerThe Apollo player that was unregistered.
ApolloPlayerHandshakeEvent

ApolloPlayerHandshakeEvent

Called when the client sends a PlayerHandshakeMessage.

FieldDescription
ApolloPlayer playerThe Apollo player that sent the packet.
MinecraftVersion minecraftVersionThe minecraft version the player is running.
LunarClientVersion lunarClientVersionThe Lunar Client version the player is running.
List<LunarClientMod> installedModsList of all internal and external mods the player has running.
Minecraft Version Information
All MinecraftVersion minecraftVersion Versions
  • V1_7
  • V1_8
  • V1_9
  • V1_10
  • V1_11
  • V1_12
  • V1_16_1
  • V1_16_5
  • V1_17_0
  • V1_17_1
  • V1_18_1
  • V1_18_2
  • V1_19_pre
  • V1_19_0
  • V1_19_2
  • V1_19_3
  • V1_19_4
  • V1_20_0
  • V1_20_1
  • V1_20_2
  • V1_20_3
  • V1_20_4
  • UNKNOWN (Occurs when Apollo is outdated or hasn't been updated to include new Minecraft versions.)
⚠️
This list may not consistently reflect the most up-to-date information regarding supported versions.
Lunar Client Version Information
How LunarClientVersion lunarClientVersion Works

This returns all the attributes about the version of Lunar Client the player is using.

AttributesDescription
gitBranchThe current branch of Lunar Client. (e.g. 'master')
gitCommitThe current commit of the branch.
semVerThe versions semver encoding. (e.g. '2.5.1')
LunarClientMod (Installed Mods) Information
How List<LunarClientMod> installedMods Works

This returns a list of each mod, and its respective attributes.

Mod Attributes

AttributesDescription
idThe unique identifier for the mod. (e.g. 'sodium')
displayNameThe human-readable/user-friendly display name. (e.g. 'Sodium')
versionThe current version of the mod. (e.g. '1.2.21')
typeThe type of mod it's classified as. (e.g. 'FABRIC_INTERNAL')

The Different Type of Mods

TypeDescription
FABRIC_INTERNALA fabric mod that is shipped with Lunar Client.
FABRIC_EXTERNALA fabric mod that is loaded by the Player.
FORGE_INTERNALA forge mod that is shipped with Lunar Client.
FORGE_EXTERNALA forge mod that is loaded by the Player.
ApolloReceivePacketEvent

ApolloReceivePacketEvent

Called when the Apollo player receives an Apollo packet from Lunar Client.

FieldDescription
ApolloPlayer playerThe Apollo player that received the packet.
Any packetThe Apollo packet that was received.
ApolloSendPacketEvent

ApolloSendPacketEvent

Called when the Apollo player sends an Apollo packet to Lunar Client.

FieldDescription
ApolloPlayer playerThe Apollo player that sent the packet.
Any packetThe Apollo packet that was sent.
This event is cancellable.
ApolloUpdateOptionEvent

ApolloUpdateOptionEvent

Called when an option is updated.

FieldDescription
Options containerThe container that the option is in.
ApolloPlayer playerThe Apollo player the option was updated for, or null if it was a global option.
Option<?, ?, ?> optionThe option that was updated.
Object valueThe new value of the option.
This event is cancellable.
ApolloPlayerChatCloseEvent

ApolloPlayerChatCloseEvent

Called when the player closes their chat.

FieldDescription
long instantiationTimeMsThe unix timestamp when the packet was created.
PlayerInfo playerInfoThe player's general information.
ApolloPlayerChatOpenEvent

ApolloPlayerChatOpenEvent

Called when the player opens their chat.

FieldDescription
long instantiationTimeMsThe unix timestamp when the packet was created.
PlayerInfo playerInfoThe player's general information.
ApolloPlayerAttackEvent

ApolloPlayerAttackEvent

Called when the player attacks another player.

FieldDescription
long instantiationTimeMsThe unix timestamp when the packet was created.
PlayerInfo targetInfoThe target player general information.
PlayerInfo attackerInfoThe attacker player general information.
double distanceThe reach distance the attacker hit a player from.
ApolloPlayerUseItemEvent

ApolloPlayerUseItemEvent

Called when the player uses an item (1.16.1+).

FieldDescription
long instantiationTimeMsThe unix timestamp when the packet was created.
PlayerInfo playerInfoThe player's general information.
boolean mainHandWhether the item was in the player's main hand.

Integration

Sample Code (Method 1)

public class GeneralExample1 implements ApolloListener {
 
    public GeneralExample1() {
        EventBus.getBus().register(this);
    }
 
    @Listen
    public void onApolloRegister(ApolloRegisterPlayerEvent event) {
        ((Player) event.getPlayer().getPlayer()).sendMessage("You have joined using LunarClient!");
    }
}

Sample Code (Method 2)

public class GeneralExample2 implements ApolloListener {
 
    public GeneralExample2() {
        this.handle(ApolloRegisterPlayerEvent.class, this::onApolloRegister);
    }
 
    public void onApolloRegister(ApolloRegisterPlayerEvent event) {
        ((Player) event.getPlayer().getPlayer()).sendMessage("You have joined using LunarClient!");
    }
}

Creating Apollo events

Creating the event class

// Normal event
public class CoolApolloEvent implements Event {
 
    private final ApolloPlayer player;
 
    public CoolApolloEvent(ApolloPlayer player) {
        this.player = player;
    }
 
    public ApolloPlayer getPlayer() {
        return this.player;
    }
}
 
// Cancellable event
public class CoolApolloCancellableEvent implements EventCancellable {
 
    private final ApolloPlayer player;
 
    private boolean cancelled;
 
    public CoolApolloCancellableEvent(ApolloPlayer player) {
        this.player = player;
    }
 
    public ApolloPlayer getPlayer() {
        return this.player;
    }
 
    @Override
    public boolean isCancelled() {
        return this.cancelled;
    }
 
    @Override
    public void setCancelled(boolean cancel) {
        this.cancelled = cancel;
    }
}

Calling the created event

// Calling a normal event
public void callCoolApolloEvent(ApolloPlayer player) {
    CoolApolloEvent event = new CoolApolloEvent(player);
    EventBus.EventResult<CoolApolloEvent> result = EventBus.getBus().post(event);
 
    for (Throwable throwable : result.getThrowing()) {
        throwable.printStackTrace();
    }
}
 
// Calling a cancellable event
public void callCoolApolloCancellableEvent(ApolloPlayer player) {
    CoolApolloCancellableEvent event = new CoolApolloCancellableEvent(player);
    EventBus.EventResult<CoolApolloCancellableEvent> result = EventBus.getBus().post(event);
 
    if (!result.getEvent().isCancelled()) {
        // Do some action if the event is not cancelled
    }
 
    for (Throwable throwable : result.getThrowing()) {
        throwable.printStackTrace();
    }
}