Apollo
Developers
Modules
Mod Setting

Mod Setting Module

Overview

The mod setting module allows you to interact with Lunar Client players mods and settings of those mods.

This module heavily integrates with our Options API. You can find all available mods and their options under the mods section.

  • Adds the ability to interact with Lunar Client mods.
    • Ability to enable/disable mods.
    • Ability to change, enable or disable mod settings within a mod.
    • Ability to retrieve the current value of any mod and settings within a mod.

Mod Settings Module Example

When mods are disabled on the server, players will receive a notification!

Integration

Setting Status API

The Setting Status API provides a simple way to retrieve the current value of any mod or any setting within a mod.

Retrieve the current value for options

private final ModSettingModule modSettingModule = Apollo.getModuleManager().getModule(ModSettingModule.class);
 
private void printOptionStatusExample(Player player) {
    Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(player.getUniqueId());
    apolloPlayerOpt.ifPresent(apolloPlayer -> {
        // https://lunarclient.dev/apollo/developers/mods/waypoints#available-options
        boolean waypointsEnabled = this.modSettingModule.getStatus(apolloPlayer, ModWaypoints.ENABLED);
 
        // https://lunarclient.dev/apollo/developers/mods/minimap#available-options
        float minimapScale = this.modSettingModule.getStatus(apolloPlayer, ModMinimap.SCALE);
 
        // https://lunarclient.dev/apollo/developers/mods/fov#available-options
        int fovDefaultFov = this.modSettingModule.getStatus(apolloPlayer, ModFov.DEFAULT_FOV);
 
        apolloPlayer.sendMessage(Component.text("Waypoints Enabled: ")
            .append(Component.text(waypointsEnabled)));
 
        apolloPlayer.sendMessage(Component.text("Minimap Scale: ")
            .append(Component.text(minimapScale)));
 
        apolloPlayer.sendMessage(Component.text("Fov Default Fov: ")
            .append(Component.text(fovDefaultFov)));
    });
}

Listening for Updates

Apollo fires the ApolloUpdateModOptionEvent, whenever a Lunar Client Mod Option is updated.

import com.lunarclient.apollo.event.ApolloListener;
import com.lunarclient.apollo.event.EventBus;
import com.lunarclient.apollo.event.Listen;
import com.lunarclient.apollo.event.modsetting.ApolloUpdateModOptionEvent;
import java.util.Objects;
import net.kyori.adventure.text.Component;
 
public class ApolloModStatusExample implements ApolloListener {
 
    public ApolloModStatusExample() {
        EventBus.getBus().register(this);
    }
 
    @Listen
    private void onApolloUpdateModOption(ApolloUpdateModOptionEvent event) {
        event.getPlayer().sendMessage(Component.text(event.getOption().getKey())
            .append(Component.text(" was updated to "))
            .append(Component.text(Objects.toString(event.getValue()))));
    }
 
}

Setting Interception API

The Setting Interception API allows you to override the value of any mod option.

Explore each integration by cycling through each tab, to find the best fit for your requirements and needs.

Disable Lighting Mod

public void disableLightingModExample(Player viewer) {
    Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
    apolloPlayerOpt.ifPresent(apolloPlayer -> this.modSettingModule.getOptions().set(apolloPlayer, ModLighting.ENABLED, false));
}

Reset Lighting Mod to it's default value

public void rollbackLightingModEnabledState(Player viewer) {
    Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
    // To rollback the server override value of the setting, simply set the value to "null"
    apolloPlayerOpt.ifPresent(apolloPlayer -> this.modSettingModule.getOptions().set(apolloPlayer, ModLighting.ENABLED, null));
}

Broadcast Disable Lighting Mod the an entire server

public void broadcastDisableLightingModExample(Player viewer) {
    this.modSettingModule.getOptions().set(ModLighting.ENABLED, false);
}