Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ public abstract class StaffModModule extends ApolloModule {
*/
public abstract void enableStaffMods(Recipients recipients, List<StaffMod> mods);

/**
* Enables the {@link StaffMod}s for the {@link Recipients}.
*
* @param recipients the recipients that are receiving the packet
* @param mods the staff mods
* @param enabledByDefault whether the staff mods should be enabled by default on the client
* @since 1.2.8
*/
public abstract void enableStaffMods(Recipients recipients, List<StaffMod> mods, boolean enabledByDefault);

/**
* Disables the {@link StaffMod}s from the {@link Recipients}.
*
Expand All @@ -64,6 +74,15 @@ public abstract class StaffModModule extends ApolloModule {
*/
public abstract void enableAllStaffMods(Recipients recipients);

/**
* Enables all {@link StaffMod}s for the {@link Recipients}.
*
* @param recipients the recipients that are receiving the packet
* @param enabledByDefault whether the staff mods should be enabled by default on the client
* @since 1.2.8
*/
public abstract void enableAllStaffMods(Recipients recipients, boolean enabledByDefault);

/**
* Disables all {@link StaffMod}s from the {@link Recipients}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,18 @@ public final class StaffModModuleImpl extends StaffModModule {

@Override
public void enableStaffMods(@NonNull Recipients recipients, @NonNull List<StaffMod> mods) {
this.enableStaffMods(recipients, mods, false);
}

@Override
public void enableStaffMods(@NonNull Recipients recipients, @NonNull List<StaffMod> mods, boolean enabledByDefault) {
Set<com.lunarclient.apollo.staffmod.v1.StaffMod> staffModsProto = mods.stream()
.map(this::toProtobuf)
.collect(Collectors.toSet());

EnableStaffModsMessage message = EnableStaffModsMessage.newBuilder()
.addAllStaffMods(staffModsProto)
.setEnabledByDefault(enabledByDefault)
.build();

ApolloManager.getNetworkManager().sendPacket(recipients, message);
Expand All @@ -83,6 +89,16 @@ public void enableAllStaffMods(@NonNull Recipients recipients) {
ApolloManager.getNetworkManager().sendPacket(recipients, this.enableAllStaffModsMessage);
}

@Override
public void enableAllStaffMods(@NonNull Recipients recipients, boolean enabledByDefault) {
EnableStaffModsMessage message = EnableStaffModsMessage.newBuilder()
.addAllStaffMods(this.staffMods)
.setEnabledByDefault(enabledByDefault)
.build();

ApolloManager.getNetworkManager().sendPacket(recipients, message);
}

@Override
public void disableAllStaffMods(@NonNull Recipients recipients) {
ApolloManager.getNetworkManager().sendPacket(recipients, this.disableAllStaffModsMessage);
Expand Down
6 changes: 3 additions & 3 deletions docs/developers/lightweight/protobuf.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Available fields for each message, including their types, are available on the B
<dependency>
<groupId>com.lunarclient</groupId>
<artifactId>apollo-protos</artifactId>
<version>0.1.8</version>
<version>0.2.0</version>
</dependency>
</dependencies>
```
Expand All @@ -41,7 +41,7 @@ Available fields for each message, including their types, are available on the B
}

dependencies {
api 'com.lunarclient:apollo-protos:0.1.8'
api 'com.lunarclient:apollo-protos:0.2.0'
}
```
</Tab>
Expand All @@ -55,7 +55,7 @@ Available fields for each message, including their types, are available on the B
}

dependencies {
api("com.lunarclient:apollo-protos:0.1.8")
api("com.lunarclient:apollo-protos:0.2.0")
}
```
</Tab>
Expand Down
6 changes: 5 additions & 1 deletion docs/developers/modules/staffmod.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void enableStaffModsExample(Player viewer) {
}

Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(apolloPlayer -> this.staffModModule.enableStaffMods(apolloPlayer, Collections.singletonList(StaffMod.XRAY)));
apolloPlayerOpt.ifPresent(apolloPlayer -> this.staffModModule.enableStaffMods(apolloPlayer, Collections.singletonList(StaffMod.XRAY), true));
}
```

Expand All @@ -56,6 +56,8 @@ public void disableStaffModsExample(Player viewer) {
- A list of all the player(s) you want to enable or disable the staff mod.
2. `StaffMod.TYPE`
- The type of staff mod(s) you want to enable for the `Recipients` player. See the [staff mod types](#staffmod-types) section for more.
3. `boolean enabledByDefault`
- Only available on `enableStaffMods`. When `true`, the staff mod is automatically enabled on the player's client; when `false`, it is unlocked but left disabled for the player to toggle on themselves.

## `StaffMod` Types

Expand All @@ -79,6 +81,7 @@ public void enableStaffModsExample(Player viewer) {

EnableStaffModsMessage message = EnableStaffModsMessage.newBuilder()
.addAllStaffMods(Collections.singletonList(StaffMod.STAFF_MOD_XRAY))
.setEnabledByDefault(true)
.build();

ProtobufPacketUtil.sendPacket(viewer, message);
Expand Down Expand Up @@ -121,6 +124,7 @@ public void enableStaffModsExample(Player viewer) {
JsonObject message = new JsonObject();
message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.staffmod.v1.EnableStaffModsMessage");
message.add("staff_mods", staffMods);
message.addProperty("enabled_by_default", true);

JsonPacketUtil.sendPacket(viewer, message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void enableStaffModsExample(Player viewer) {
}

Optional<ApolloPlayer> apolloPlayerOpt = Apollo.getPlayerManager().getPlayer(viewer.getUniqueId());
apolloPlayerOpt.ifPresent(apolloPlayer -> this.staffModModule.enableStaffMods(apolloPlayer, Collections.singletonList(StaffMod.XRAY)));
apolloPlayerOpt.ifPresent(apolloPlayer -> this.staffModModule.enableStaffMods(apolloPlayer, Collections.singletonList(StaffMod.XRAY), true));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void enableStaffModsExample(Player viewer) {
JsonObject message = new JsonObject();
message.addProperty("@type", "type.googleapis.com/lunarclient.apollo.staffmod.v1.EnableStaffModsMessage");
message.add("staff_mods", staffMods);
message.addProperty("enabled_by_default", true);

JsonPacketUtil.sendPacket(viewer, message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public void enableStaffModsExample(Player viewer) {

EnableStaffModsMessage message = EnableStaffModsMessage.newBuilder()
.addAllStaffMods(Collections.singletonList(StaffMod.STAFF_MOD_XRAY))
.setEnabledByDefault(true)
.build();

ProtobufPacketUtil.sendPacket(viewer, message);
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ geantyref = "1.3.11"
idea = "1.1.7"
jetbrains = "24.0.1"
lombok = "1.18.38"
protobuf = "0.1.8"
protobuf = "0.2.0"
gson = "2.10.1"
shadow = "9.4.1"
spotless = "8.4.0"
Expand Down
Loading