General
Common Patterns
These are general features and how-to's inside of Apollo. You will see these options appear throughout Apollo and while reading the documentation.
We recommend you use and understand these general features.
Sending Apollo data after a player joins
Do not rely on the PlayerJoinEvent as the moment to send Apollo module packets to a player. At join time the client has often not completed the Apollo registration handshake yet, so your packets can be dropped or have no effect.
Listen for ApolloRegisterPlayerEvent instead. It fires once Lunar Client has registered with the server after the client completes the registration flow Apollo expects. That is the right place to apply initial module state, waypoints, and similar setup.
Player
Checking if player is running Lunar Client
boolean runningLunarClient = Apollo.getPlayerManager().hasSupport(player.getUniqueId());Getting an ApolloPlayer object by player UUID
Optional<ApolloPlayer> apolloPlayer = Apollo.getPlayerManager().getPlayer(player.getUniqueId());Get all players running Lunar Client
Collection<ApolloPlayer> playersRunningLunarClient = Apollo.getPlayerManager().getPlayers();Module
Get a specific module
BorderModule borderModule = Apollo.getModuleManager().getModule(BorderModule.class);Recipients
Creating recipients with a single Apollo Player
apolloPlayer.ifPresent(apolloPlayerObject -> {
Recipients recipients = apolloPlayerObject;
});Creating recipients with all players running Lunar Client
Recipients allRecipients = Recipients.ofEveryone();Creating recipients with all players running Lunar Client with names shorter than 6 characters
Recipients filteredRecipients = Recipients.of(
Apollo.getPlayerManager().getPlayers().stream()
.filter(online -> online.getName().length() < 6)
.collect(Collectors.toList())
);