Apollo
Developers
Modules
Cooldown

Cooldown Module

Overview

Apollo's cooldown module allows servers to interact with the Cooldown mod found within Lunar Client.

  • Create your own cooldowns for the Lunar Client cooldown mod.
    • Add your own custom icon, visible within the cooldown.
    • Set your own duration for each cooldown.

Integration

Sample Code

public void displayCooldownExample(Player viewer) {
    Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
 
    apolloPlayerOpt.ifPresent(apolloPlayer -> {
        this.cooldownModule.displayCooldown(apolloPlayer, Cooldown.builder()
            .name("enderpearl-cooldown")
            .duration(Duration.ofSeconds(15))
            .icon(ItemStackIcon.builder()
                .itemId(Material.ENDER_PEARL.getId())
                .build()
            )
            .build()
        );
    });
}

Cooldown Options

.name(String) should include a unique identifier for the each cooldown.

.name("enderpearl-cooldown")

.duration(java.time.Duration) the duration the cooldown should last for. See the java.time.Duration Javadocs (opens in a new tab) for more.

.duration(Duration.ofSeconds(15))

.icon(itemStackIcon) is how you display a custom icon. Read the icons utilities page to learn more about icons.

.icon(ItemStackIcon.builder().itemId(Material.ENDER_PEARL.getId()).build())

Removing a specific cooldown for a player

public void removeCooldownExample(Player viewer) {
    Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
    apolloPlayerOpt.ifPresent(apolloPlayer -> this.cooldownModule.removeCooldown(apolloPlayer, "enderpearl-cooldown"));
}

Resetting all cooldowns for a player

public void resetCooldownsExample(Player viewer) {
    Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
    apolloPlayerOpt.ifPresent(this.cooldownModule::resetCooldowns);
}