Stopwatch Module
Overview
The stopwatch module allows you to control the stopwatch mod inside Lunar Client.
- Ability to fully control a player's stopwatch mod.
- Start a player's stopwatch
- Stop a player's stopwatch
- Reset a player's stopwatch

Integration
Sample Code
Explore each integration by cycling through each tab, to find the best fit for your requirements and needs.
Adding a Stopwatch
public void addStopwatchExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(apolloPlayer -> {
this.stopwatchModule.addStopwatch(apolloPlayer, Stopwatch.builder()
.id("parkour-stopwatch")
.name("Parkour")
.resetOnStart(true)
.preventModification(true)
.hideWhenStopped(false)
.customFormat("mm:ss")
.textColor(ApolloColors.DARK_AQUA)
.hudPosition(HudPosition.builder()
.x(-30)
.y(30)
.build()
)
.build());
});
}Removing a Stopwatch
public void removeStopwatchExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(apolloPlayer -> this.stopwatchModule.removeStopwatch(apolloPlayer, "parkour-stopwatch"));
}Starting a Stopwatch
public void startStopwatchExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(apolloPlayer -> this.stopwatchModule.startStopwatch(apolloPlayer, "parkour-stopwatch"));
}Stopping a Stopwatch
public void stopStopwatchExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(apolloPlayer -> this.stopwatchModule.stopStopwatch(apolloPlayer, "parkour-stopwatch"));
}Resetting a Stopwatch
public void resetStopwatchExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(apolloPlayer -> this.stopwatchModule.resetStopwatch(apolloPlayer, "parkour-stopwatch"));
}Resetting all Stopwatches
public void resetStopwatchesExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(this.stopwatchModule::resetStopwatches);
}Adding a Timer
public void addTimerExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(apolloPlayer -> {
this.stopwatchModule.addTimer(apolloPlayer, Timer.builder()
.id("game-timer")
.name("Countdown")
.duration(Duration.ofSeconds(45))
.loop(false)
.preventModification(true)
.hideWhenStopped(false)
.customFormat("mm:ss")
.titleText(Component.text("Time's up!", NamedTextColor.RED))
.ingameNotification(true)
.textColor(ApolloColors.LIGHT_PURPLE)
.hudPosition(HudPosition.builder()
.x(-10)
.y(30)
.build()
)
.build());
});
}Removing a Timer
public void removeTimerExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(apolloPlayer -> this.stopwatchModule.removeTimer(apolloPlayer, "game-timer"));
}Starting a Timer
public void startTimerExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(apolloPlayer -> this.stopwatchModule.startTimer(apolloPlayer, "game-timer"));
}Stopping a Timer
public void stopTimerExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(apolloPlayer -> this.stopwatchModule.stopTimer(apolloPlayer, "game-timer"));
}Resetting a Timer
public void resetTimerExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(apolloPlayer -> this.stopwatchModule.resetTimer(apolloPlayer, "game-timer"));
}Resetting all Timers
public void resetTimersExample(Player viewer) {
Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(this.stopwatchModule::resetTimers);
}Stopwatch Options
.id(String) is the unique server-assigned id for the stopwatch.
.id("parkour-stopwatch").name(String) is the HUD display name.
.name("Parkour").resetOnStart(boolean) determines whether to reset elapsed time on each start.
.resetOnStart(true).preventModification(boolean) prevents the user from modifying the options for this stopwatch on the client side.
.preventModification(true).hideWhenStopped(boolean) determines whether the stopwatch is hidden from the HUD when stopped.
.hideWhenStopped(false).customFormat(String) is a format string (e.g. "mm:ss"). Uses the default display format if not provided.
.customFormat("mm:ss").textColor(java.awt.Color) is the text color. Defaults to white if not provided. See the colors page for more.
.textColor(ApolloColors.DARK_AQUA).hudPosition(HudPosition) is the HUD position on the client screen. If not provided, the stopwatch is auto-stacked.
.hudPosition(HudPosition.builder().x(-30).y(30).build())Timer Options
.id(String) is the unique server-assigned id for the timer.
.id("game-timer").name(String) is the HUD display name.
.name("Countdown").duration(java.time.Duration) is the countdown duration.
.duration(Duration.ofSeconds(45)).loop(boolean) determines whether the timer restarts automatically when finished.
.loop(false).preventModification(boolean) prevents the user from modifying the options for this timer on the client side.
.preventModification(true).hideWhenStopped(boolean) determines whether the timer is hidden from the HUD when stopped.
.hideWhenStopped(false).customFormat(String) is a format string. Uses the default display format if not provided.
.customFormat("mm:ss").titleText(Component) is the on-screen title shown when the timer finishes. Set to null or omit to skip. See the chat components (opens in a new tab) page for more.
.titleText(Component.text("Time's up!", NamedTextColor.RED)).ingameNotification(boolean) determines whether to show an in-game popup when the timer finishes.
.ingameNotification(true).textColor(java.awt.Color) is the text color. Defaults to white if not provided. See the colors page for more.
.textColor(ApolloColors.LIGHT_PURPLE).hudPosition(HudPosition) is the HUD position on the client screen. If not provided, the timer is auto-stacked.
.hudPosition(HudPosition.builder().x(-10).y(30).build())