Skip to content

Commit 41b1270

Browse files
committed
Markdown docs
1 parent 6da26e0 commit 41b1270

File tree

6 files changed

+111
-12
lines changed

6 files changed

+111
-12
lines changed

api/src/main/java/com/lunarclient/apollo/player/ApolloPlayer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ default boolean hasPermission(Options options, Option<String, ?, ?> option) {
147147

148148
/**
149149
* Returns the {@link ModStatus} interface used for retrieving
150-
* the current value of a mod options.
150+
* the current value of mod options.
151151
*
152152
* @return the mod status interface
153153
* @since 1.2.1

common/src/main/java/com/lunarclient/apollo/mods/ModStatusImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import lombok.RequiredArgsConstructor;
3131

3232
/**
33-
* Default implementation of {@link ModStatus} used to retrieve the current status of a mod option.
33+
* Default implementation of {@link ModStatus} used for retrieving the current status of a mod option.
3434
*
3535
* @since 1.2.1
3636
*/

docs/developers/_meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"options": "Options",
66
"modules": "Modules",
77
"mods": "Mods",
8+
"mod-status": "Mod Status",
89
"utilities": "Utilities",
910
"platform-utilities": "Platform Utilities",
1011
"adventure": "Adventure",

docs/developers/events.mdx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ _Called when the Apollo player sends an Apollo packet to Lunar Client._
161161

162162
### ApolloUpdateOptionEvent
163163

164-
_Called when an option is updated._
164+
_Called when an Apollo option is updated._
165165

166166
| Field | Description |
167167
| ------------------------ | -------------------------------------------------------------------------------- |
@@ -174,6 +174,21 @@ _Called when an option is updated._
174174

175175
</details>
176176

177+
<details>
178+
<summary>ApolloUpdateModOptionEvent</summary>
179+
180+
### ApolloUpdateModOptionEvent
181+
182+
_Called when a Lunar Client Mod option is updated._
183+
184+
| Field | Description |
185+
| ------------------------ | --------------------------------------------- |
186+
| `ApolloPlayer player` | The Apollo player the option was updated for. |
187+
| `Option<?, ?, ?> option` | The option that was updated. |
188+
| `Object value` | The new value of the option. |
189+
190+
</details>
191+
177192
<details>
178193
<summary>ApolloPlayerChatCloseEvent</summary>
179194

docs/developers/mod-status.mdx

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { Callout } from 'nextra-theme-docs'
2+
3+
# Mod Status
4+
5+
The Mod Status API allows you to get the current values for a player's Lunar Client mod options.
6+
7+
<Callout type="info">
8+
This API heavily integrates with our [Options API](/developers/options).
9+
You can find all available mods and their options under the mods section.
10+
</Callout>
11+
12+
## Integration
13+
14+
### Retrieve the current value for options
15+
16+
```java
17+
private void printOptionStatusExample(Player player) {
18+
Apollo.getPlayerManager().getPlayer(player.getUniqueId()).ifPresent(apolloPlayer -> {
19+
ModStatus status = apolloPlayer.getModStatus();
20+
21+
if (status == null) {
22+
// Handshake not received yet
23+
return;
24+
}
25+
26+
boolean waypointsEnabled = status.get(ModWaypoints.ENABLED);
27+
float minimapScale = status.get(ModMinimap.SCALE);
28+
int fovDefaultFov = status.get(ModFov.DEFAULT_FOV);
29+
30+
apolloPlayer.sendMessage(Component.text("Waypoints Enabled: ")
31+
.append(Component.text(waypointsEnabled)));
32+
33+
apolloPlayer.sendMessage(Component.text("Minimap Scale: ")
34+
.append(Component.text(minimapScale)));
35+
36+
apolloPlayer.sendMessage(Component.text("Fov Default Fov: ")
37+
.append(Component.text(fovDefaultFov)));
38+
});
39+
}
40+
```
41+
42+
### Listening for Updates
43+
44+
Apollo provides an event, `[ApolloUpdateModOptionEvent](/developers/events)`, that is fired whenever a Lunar Client Mod Option is updated.
45+
46+
```java
47+
import com.lunarclient.apollo.event.ApolloListener;
48+
import com.lunarclient.apollo.event.EventBus;
49+
import com.lunarclient.apollo.event.Listen;
50+
import com.lunarclient.apollo.event.mods.ApolloUpdateModOptionEvent;
51+
import java.util.Objects;
52+
import net.kyori.adventure.text.Component;
53+
54+
public class ApolloModStatusExample implements ApolloListener {
55+
56+
public ApolloModStatusExample() {
57+
EventBus.getBus().register(this);
58+
}
59+
60+
@Listen
61+
private void onApolloUpdateModOption(ApolloUpdateModOptionEvent event) {
62+
event.getPlayer().sendMessage(Component.text(event.getOption().getKey())
63+
.append(Component.text(" was updated to "))
64+
.append(Component.text(Objects.toString(event.getValue()))));
65+
}
66+
67+
}
68+
```

example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/mods/ApolloModStatusExample.java

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@
3030
import com.lunarclient.apollo.event.mods.ApolloUpdateModOptionEvent;
3131
import com.lunarclient.apollo.example.ApolloExamplePlugin;
3232
import com.lunarclient.apollo.mods.ModStatus;
33-
import com.lunarclient.apollo.mods.impl.ModFreelook;
33+
import com.lunarclient.apollo.mods.impl.ModFov;
3434
import com.lunarclient.apollo.mods.impl.ModMinimap;
3535
import com.lunarclient.apollo.mods.impl.ModWaypoints;
3636
import java.util.Objects;
3737
import net.kyori.adventure.text.Component;
3838
import org.bukkit.Bukkit;
39+
import org.bukkit.Material;
3940
import org.bukkit.entity.Player;
4041
import org.bukkit.event.EventHandler;
4142
import org.bukkit.event.Listener;
@@ -55,24 +56,38 @@ private void onApolloUpdateModOption(ApolloUpdateModOptionEvent event) {
5556
.append(Component.text(Objects.toString(event.getValue()))));
5657
}
5758

58-
@EventHandler(ignoreCancelled = true)
59+
@EventHandler
5960
private void onBlockPlace(BlockPlaceEvent event) {
6061
Player player = event.getPlayer();
6162

63+
if (event.getBlock().getType() != Material.DIAMOND_BLOCK) {
64+
return;
65+
}
66+
67+
this.printOptionStatusExample(player);
68+
}
69+
70+
private void printOptionStatusExample(Player player) {
6271
Apollo.getPlayerManager().getPlayer(player.getUniqueId()).ifPresent(apolloPlayer -> {
6372
ModStatus status = apolloPlayer.getModStatus();
6473

65-
apolloPlayer.sendMessage(Component.text("Waypoints Enabled: ")
66-
.append(Component.text(status.get(ModWaypoints.ENABLED))));
74+
if (status == null) {
75+
// Handshake not received yet
76+
return;
77+
}
6778

68-
apolloPlayer.sendMessage(Component.text("Freelook Invert Yaw: ")
69-
.append(Component.text(status.get(ModFreelook.INVERT_YAW))));
79+
boolean waypointsEnabled = status.get(ModWaypoints.ENABLED);
80+
float minimapScale = status.get(ModMinimap.SCALE);
81+
int fovDefaultFov = status.get(ModFov.DEFAULT_FOV);
7082

71-
apolloPlayer.sendMessage(Component.text("Freelook Invert Pitch: ")
72-
.append(Component.text(status.get(ModFreelook.INVERT_PITCH))));
83+
apolloPlayer.sendMessage(Component.text("Waypoints Enabled: ")
84+
.append(Component.text(waypointsEnabled)));
7385

7486
apolloPlayer.sendMessage(Component.text("Minimap Scale: ")
75-
.append(Component.text(status.get(ModMinimap.SCALE))));
87+
.append(Component.text(minimapScale)));
88+
89+
apolloPlayer.sendMessage(Component.text("Fov Default Fov: ")
90+
.append(Component.text(fovDefaultFov)));
7691
});
7792
}
7893

0 commit comments

Comments
 (0)