diff --git a/api/src/main/java/com/lunarclient/apollo/module/staffmod/StaffModModule.java b/api/src/main/java/com/lunarclient/apollo/module/staffmod/StaffModModule.java index ed1d9999..75c648d6 100644 --- a/api/src/main/java/com/lunarclient/apollo/module/staffmod/StaffModModule.java +++ b/api/src/main/java/com/lunarclient/apollo/module/staffmod/StaffModModule.java @@ -47,6 +47,16 @@ public abstract class StaffModModule extends ApolloModule { */ public abstract void enableStaffMods(Recipients recipients, List 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 mods, boolean enabledByDefault); + /** * Disables the {@link StaffMod}s from the {@link Recipients}. * @@ -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}. * diff --git a/common/src/main/java/com/lunarclient/apollo/module/staffmod/StaffModModuleImpl.java b/common/src/main/java/com/lunarclient/apollo/module/staffmod/StaffModModuleImpl.java index 6ccb5aa6..6b316755 100644 --- a/common/src/main/java/com/lunarclient/apollo/module/staffmod/StaffModModuleImpl.java +++ b/common/src/main/java/com/lunarclient/apollo/module/staffmod/StaffModModuleImpl.java @@ -54,12 +54,18 @@ public final class StaffModModuleImpl extends StaffModModule { @Override public void enableStaffMods(@NonNull Recipients recipients, @NonNull List mods) { + this.enableStaffMods(recipients, mods, false); + } + + @Override + public void enableStaffMods(@NonNull Recipients recipients, @NonNull List mods, boolean enabledByDefault) { Set staffModsProto = mods.stream() .map(this::toProtobuf) .collect(Collectors.toSet()); EnableStaffModsMessage message = EnableStaffModsMessage.newBuilder() .addAllStaffMods(staffModsProto) + .setEnabledByDefault(enabledByDefault) .build(); ApolloManager.getNetworkManager().sendPacket(recipients, message); @@ -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); diff --git a/docs/developers/lightweight/protobuf.mdx b/docs/developers/lightweight/protobuf.mdx index d18643bf..f39b9e45 100644 --- a/docs/developers/lightweight/protobuf.mdx +++ b/docs/developers/lightweight/protobuf.mdx @@ -26,7 +26,7 @@ Available fields for each message, including their types, are available on the B com.lunarclient apollo-protos - 0.1.8 + 0.2.0 ``` @@ -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' } ``` @@ -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") } ``` diff --git a/docs/developers/modules/staffmod.mdx b/docs/developers/modules/staffmod.mdx index 92f02101..8c547999 100644 --- a/docs/developers/modules/staffmod.mdx +++ b/docs/developers/modules/staffmod.mdx @@ -37,7 +37,7 @@ public void enableStaffModsExample(Player viewer) { } Optional 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)); } ``` @@ -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 @@ -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); @@ -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); } diff --git a/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/StaffModApiExample.java b/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/StaffModApiExample.java index 6deaa3dd..d38ae3da 100644 --- a/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/StaffModApiExample.java +++ b/example/bukkit/api/src/main/java/com/lunarclient/apollo/example/api/module/StaffModApiExample.java @@ -43,7 +43,7 @@ public void enableStaffModsExample(Player viewer) { } Optional 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 diff --git a/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/StaffModJsonExample.java b/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/StaffModJsonExample.java index 9967db00..ee0d0d87 100644 --- a/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/StaffModJsonExample.java +++ b/example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/module/StaffModJsonExample.java @@ -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); } diff --git a/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/StaffModProtoExample.java b/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/StaffModProtoExample.java index baabe174..9af09b1a 100644 --- a/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/StaffModProtoExample.java +++ b/example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/module/StaffModProtoExample.java @@ -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); diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9389be29..d83b4d64 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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"