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 displayCooldownItemExample(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()
                .itemName("ENDER_PEARL")
                .build()
            )
            .build()
        );
    });
}
 
public void displayCooldownResourceExample(Player viewer) {
    Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
 
    apolloPlayerOpt.ifPresent(apolloPlayer -> {
        this.cooldownModule.displayCooldown(apolloPlayer, Cooldown.builder()
            .name("lunar-cooldown")
            .duration(Duration.ofSeconds(15))
            .icon(SimpleResourceLocationIcon.builder()
                .resourceLocation("lunar:logo/logo-200x182.svg")
                .size(12)
                .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 item icon. Read the icons utilities page to learn more about icons.

.icon(ItemStackIcon.builder().itemId("ENDER_PEARL").build())

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

.icon(SimpleResourceLocationIcon.builder().resourceLocation("lunar:logo/logo-200x182.svg").size(12).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");
        this.cooldownModule.removeCooldown(apolloPlayer, "lunar-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);
}