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
ApolloUnregisterPlayerEvent
ApolloPlayerHandshakeEvent
ApolloPlayerHandshakeEvent
Called when the client sends a PlayerHandshakeMessage.
Field | Description |
---|---|
ApolloPlayer player | The Apollo player that sent the packet. |
MinecraftVersion minecraftVersion | The minecraft version the player is running. |
LunarClientVersion lunarClientVersion | The Lunar Client version the player is running. |
List<LunarClientMod> installedMods | List 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.
Attributes | Description |
---|---|
gitBranch | The current branch of Lunar Client. (e.g. 'master') |
gitCommit | The current commit of the branch. |
semVer | The 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
Attributes | Description |
---|---|
id | The unique identifier for the mod. (e.g. 'sodium') |
displayName | The human-readable/user-friendly display name. (e.g. 'Sodium') |
version | The current version of the mod. (e.g. '1.2.21') |
type | The type of mod it's classified as. (e.g. 'FABRIC_INTERNAL') |
The Different Type
of Mods
Type | Description |
---|---|
FABRIC_INTERNAL | A fabric mod that is shipped with Lunar Client. |
FABRIC_EXTERNAL | A fabric mod that is loaded by the Player. |
FORGE_INTERNAL | A forge mod that is shipped with Lunar Client. |
FORGE_EXTERNAL | A forge mod that is loaded by the Player. |
ApolloReceivePacketEvent
ApolloSendPacketEvent
ApolloUpdateOptionEvent
ApolloUpdateOptionEvent
Called when an option is updated.
Field | Description |
---|---|
Options container | The container that the option is in. |
ApolloPlayer player | The Apollo player the option was updated for, or null if it was a global option. |
Option<?, ?, ?> option | The option that was updated. |
Object value | The new value of the option. |
This event is cancellable.
ApolloPlayerChatCloseEvent
ApolloPlayerChatOpenEvent
ApolloPlayerAttackEvent
ApolloPlayerAttackEvent
Called when the player attacks another player.
Field | Description |
---|---|
long instantiationTimeMs | The unix timestamp when the packet was created. |
PlayerInfo targetInfo | The target player general information. |
PlayerInfo attackerInfo | The attacker player general information. |
double distance | The reach distance the attacker hit a player from. |
ApolloPlayerUseItemEvent
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();
}
}