Skip to content

Commit 62f2856

Browse files
Stopwatch Module v2 (#272)
* Stopwatch module overhaul * Add `hideWhenStopped` to stopwatches & timers * Update Module Overview * Overview touchups * fix typos * format fix * update fields to match protos --------- Co-authored-by: Trentin <25537885+TrentinTheKid@users.noreply.github.com>
1 parent 923a023 commit 62f2856

13 files changed

Lines changed: 1622 additions & 39 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* This file is part of Apollo, licensed under the MIT License.
3+
*
4+
* Copyright (c) 2026 Moonsworth
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
package com.lunarclient.apollo.common.location;
25+
26+
import lombok.Builder;
27+
import lombok.Getter;
28+
29+
/**
30+
* Represents a HUD element position on the client screen.
31+
*
32+
* @since 1.2.6
33+
*/
34+
@Getter
35+
@Builder
36+
public final class HudPosition {
37+
38+
/**
39+
* Returns the {@code float} X coordinate for this HUD position.
40+
*
41+
* @return the x coordinate
42+
* @since 1.2.6
43+
*/
44+
float x;
45+
46+
/**
47+
* Returns the {@code float} Y coordinate for this HUD position.
48+
*
49+
* @return the y coordinate
50+
* @since 1.2.6
51+
*/
52+
float y;
53+
54+
}

api/src/main/java/com/lunarclient/apollo/module/cooldown/CooldownStyle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import org.jetbrains.annotations.Nullable;
3030

3131
/**
32-
* Represents the {@link Cooldown} style, allowing customization of the circle start, end, edge & text color.
32+
* Represents the {@link Cooldown} style, allowing customization of the circle start, end, edge and text color.
3333
*
3434
* @since 1.2.5
3535
*/
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*
2+
* This file is part of Apollo, licensed under the MIT License.
3+
*
4+
* Copyright (c) 2026 Moonsworth
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in all
14+
* copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
* SOFTWARE.
23+
*/
24+
package com.lunarclient.apollo.module.stopwatch;
25+
26+
import com.lunarclient.apollo.common.location.HudPosition;
27+
import java.awt.Color;
28+
import lombok.Builder;
29+
import lombok.Getter;
30+
import org.jetbrains.annotations.Nullable;
31+
32+
/**
33+
* Represents a stopwatch which can be displayed on the client HUD.
34+
*
35+
* @since 1.2.6
36+
*/
37+
@Getter
38+
@Builder
39+
public final class Stopwatch {
40+
41+
/**
42+
* Returns the stopwatch {@link String} id.
43+
*
44+
* @return the stopwatch id
45+
* @since 1.2.6
46+
*/
47+
String id;
48+
49+
/**
50+
* Returns the stopwatch {@link String} name.
51+
*
52+
* @return the stopwatch name
53+
* @since 1.2.6
54+
*/
55+
String name;
56+
57+
/**
58+
* Returns the stopwatch {@code boolean} reset on start.
59+
*
60+
* <p>If {@code true}, elapsed time is reset on each start.</p>
61+
*
62+
* @return whether to reset on start
63+
* @since 1.2.6
64+
*/
65+
boolean resetOnStart;
66+
67+
/**
68+
* Returns the stopwatch {@code boolean} prevent modification.
69+
*
70+
* <p>If {@code true}, the user cannot modify the options for this
71+
* stopwatch on the client side.</p>
72+
*
73+
* @return whether modification is prevented
74+
* @since 1.2.6
75+
*/
76+
boolean preventModification;
77+
78+
/**
79+
* Returns the stopwatch {@code boolean} hide when stopped.
80+
*
81+
* <p>If {@code true}, the stopwatch is hidden from the HUD when stopped.</p>
82+
*
83+
* @return whether to hide when stopped
84+
* @since 1.2.6
85+
*/
86+
boolean hideWhenStopped;
87+
88+
/**
89+
* Returns the stopwatch {@link String} display format.
90+
*
91+
* <p>A format string (e.g. {@code "mm:ss"}), or {@code null}
92+
* for the default display format.</p>
93+
*
94+
* @return the display format string
95+
* @since 1.2.6
96+
*/
97+
@Nullable String displayFormat;
98+
99+
/**
100+
* Returns the stopwatch {@link Color} text color.
101+
*
102+
* <p>If {@code null}, the default color (white) is used.</p>
103+
*
104+
* @return the text color
105+
* @since 1.2.6
106+
*/
107+
@Nullable Color textColor;
108+
109+
/**
110+
* Returns the stopwatch {@link HudPosition} HUD position.
111+
*
112+
* <p>If {@code null}, the stopwatch is auto-stacked at the default position.</p>
113+
*
114+
* @return the HUD position
115+
* @since 1.2.6
116+
*/
117+
@Nullable HudPosition hudPosition;
118+
119+
}

api/src/main/java/com/lunarclient/apollo/module/stopwatch/StopwatchModule.java

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,28 +45,141 @@ public Collection<ApolloPlatform.Kind> getSupportedPlatforms() {
4545
return Arrays.asList(ApolloPlatform.Kind.SERVER, ApolloPlatform.Kind.PROXY);
4646
}
4747

48+
/**
49+
* Adds a {@link Stopwatch} to the HUD for the {@link Recipients}.
50+
*
51+
* @param recipients the recipients that are receiving the packet
52+
* @param stopwatch the stopwatch to add
53+
* @since 1.2.6
54+
*/
55+
public abstract void addStopwatch(Recipients recipients, Stopwatch stopwatch);
56+
57+
/**
58+
* Removes the {@link Stopwatch} with the given id for the {@link Recipients}.
59+
*
60+
* @param recipients the recipients that are receiving the packet
61+
* @param id the stopwatch id
62+
* @since 1.2.6
63+
*/
64+
public abstract void removeStopwatch(Recipients recipients, String id);
65+
66+
/**
67+
* Starts the {@link Stopwatch} with the given id for the {@link Recipients}.
68+
*
69+
* @param recipients the recipients that are receiving the packet
70+
* @param id the stopwatch id
71+
* @since 1.2.6
72+
*/
73+
public abstract void startStopwatch(Recipients recipients, String id);
74+
75+
/**
76+
* Stops the {@link Stopwatch} with the given id for the {@link Recipients}.
77+
*
78+
* @param recipients the recipients that are receiving the packet
79+
* @param id the stopwatch id
80+
* @since 1.2.6
81+
*/
82+
public abstract void stopStopwatch(Recipients recipients, String id);
83+
84+
/**
85+
* Resets the {@link Stopwatch} with the given id for the {@link Recipients}.
86+
*
87+
* @param recipients the recipients that are receiving the packet
88+
* @param id the stopwatch id
89+
* @since 1.2.6
90+
*/
91+
public abstract void resetStopwatch(Recipients recipients, String id);
92+
93+
/**
94+
* Resets all {@link Stopwatch}es for the {@link Recipients}.
95+
*
96+
* @param recipients the recipients that are receiving the packet
97+
* @since 1.2.6
98+
*/
99+
public abstract void resetStopwatches(Recipients recipients);
100+
101+
/**
102+
* Adds a {@link Timer} to the HUD for the {@link Recipients}.
103+
*
104+
* @param recipients the recipients that are receiving the packet
105+
* @param timer the timer to add
106+
* @since 1.2.6
107+
*/
108+
public abstract void addTimer(Recipients recipients, Timer timer);
109+
110+
/**
111+
* Removes the {@link Timer} with the given id for the {@link Recipients}.
112+
*
113+
* @param recipients the recipients that are receiving the packet
114+
* @param id the timer id
115+
* @since 1.2.6
116+
*/
117+
public abstract void removeTimer(Recipients recipients, String id);
118+
119+
/**
120+
* Starts the {@link Timer} with the given id for the {@link Recipients}.
121+
*
122+
* @param recipients the recipients that are receiving the packet
123+
* @param id the timer id
124+
* @since 1.2.6
125+
*/
126+
public abstract void startTimer(Recipients recipients, String id);
127+
128+
/**
129+
* Stops the {@link Timer} with the given id for the {@link Recipients}.
130+
*
131+
* @param recipients the recipients that are receiving the packet
132+
* @param id the timer id
133+
* @since 1.2.6
134+
*/
135+
public abstract void stopTimer(Recipients recipients, String id);
136+
137+
/**
138+
* Resets the {@link Timer} with the given id for the {@link Recipients}.
139+
*
140+
* @param recipients the recipients that are receiving the packet
141+
* @param id the timer id
142+
* @since 1.2.6
143+
*/
144+
public abstract void resetTimer(Recipients recipients, String id);
145+
146+
/**
147+
* Resets all {@link Timer}s for the {@link Recipients}.
148+
*
149+
* @param recipients the recipients that are receiving the packet
150+
* @since 1.2.6
151+
*/
152+
public abstract void resetTimers(Recipients recipients);
153+
48154
/**
49155
* Starts the stopwatch for the {@link Recipients}.
50156
*
51157
* @param recipients the recipients that are receiving the packet
158+
* @deprecated for removal since 1.2.6, use {@link #addStopwatch(Recipients, Stopwatch)}
159+
* and {@link #startStopwatch(Recipients, String)} instead.
52160
* @since 1.0.0
53161
*/
162+
@Deprecated
54163
public abstract void startStopwatch(Recipients recipients);
55164

56165
/**
57166
* Stops the stopwatch for the {@link Recipients}.
58167
*
59168
* @param recipients the recipients that are receiving the packet
169+
* @deprecated for removal since 1.2.6, use {@link #stopStopwatch(Recipients, String)} instead.
60170
* @since 1.0.0
61171
*/
172+
@Deprecated
62173
public abstract void stopStopwatch(Recipients recipients);
63174

64175
/**
65176
* Resets the stopwatch for the {@link Recipients}.
66177
*
67178
* @param recipients the recipients that are receiving the packet
179+
* @deprecated for removal since 1.2.6, use {@link #resetStopwatch(Recipients, String)} instead.
68180
* @since 1.0.0
69181
*/
182+
@Deprecated
70183
public abstract void resetStopwatch(Recipients recipients);
71184

72185
}

0 commit comments

Comments
 (0)