Skip to content

Commit b60f27d

Browse files
Add ALLOW_DIG_AND_USE to Combat Module (#290)
* Add CombatModule#ALLOW_ATTACK_AND_USE * Update supported versions docs for the ALLOW_ATTACK_AND_USE option * Rename to `allow-dig-and-use` & add anticheat callout * Update combat.mdx --------- Co-authored-by: Trentin <25537885+TrentinTheKid@users.noreply.github.com>
1 parent ef246bb commit b60f27d

6 files changed

Lines changed: 63 additions & 5 deletions

File tree

api/src/main/java/com/lunarclient/apollo/module/combat/CombatModule.java

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,32 @@ public final class CombatModule extends ApolloModule {
4040
/**
4141
* Whether the player gets a hit delay for a missed hit.
4242
*
43+
* <p>Enabling this option may cause compatibility issues with anti-cheats.</p>
44+
*
4345
* @since 1.0.4
4446
*/
4547
public static final SimpleOption<Boolean> DISABLE_MISS_PENALTY = Option.<Boolean>builder()
46-
.comment("Set to 'true' to remove the miss penalty on all versions 1.8 and above, otherwise 'false'.")
48+
.comment("Set to 'true' to remove the miss penalty on all versions 1.8 and above, otherwise 'false'. Enabling this option may cause compatibility issues with anti-cheats.")
4749
.node("disable-miss-penalty").type(TypeToken.get(Boolean.class))
4850
.defaultValue(false).notifyClient().build();
4951

52+
/**
53+
* Whether the player can dig and use an item at the same time,
54+
* like in 1.7. Applies to all versions 1.8 and above.
55+
*
56+
* <p>Enabling this option may cause compatibility issues with anti-cheats.</p>
57+
*
58+
* @since 1.2.8
59+
*/
60+
public static final SimpleOption<Boolean> ALLOW_DIG_AND_USE = Option.<Boolean>builder()
61+
.comment("Set to 'true' to allow digging and using an item at the same time on all versions 1.8 and above, otherwise 'false'. Enabling this option may cause compatibility issues with anti-cheats.")
62+
.node("allow-dig-and-use").type(TypeToken.get(Boolean.class))
63+
.defaultValue(false).notifyClient().build();
64+
5065
CombatModule() {
5166
this.registerOptions(
52-
CombatModule.DISABLE_MISS_PENALTY
67+
CombatModule.DISABLE_MISS_PENALTY,
68+
CombatModule.ALLOW_DIG_AND_USE
5369
);
5470
}
5571

docs/developers/lightweight/json/packet-util.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ static {
3535
// While using the Apollo plugin this would be equivalent to modifying the config.yml
3636
CONFIG_MODULE_PROPERTIES.put("colored_fire", "persist-colors-on-unload", false);
3737
CONFIG_MODULE_PROPERTIES.put("combat", "disable-miss-penalty", false);
38+
CONFIG_MODULE_PROPERTIES.put("combat", "allow-dig-and-use", false);
3839
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-attack.send-packet", false);
3940
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-open.send-packet", false);
4041
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-close.send-packet", false);

docs/developers/lightweight/protobuf/packet-util.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ static {
3535
// While using the Apollo plugin this would be equivalent to modifying the config.yml
3636
CONFIG_MODULE_PROPERTIES.put("colored_fire", "persist-colors-on-unload", Value.newBuilder().setBoolValue(false).build());
3737
CONFIG_MODULE_PROPERTIES.put("combat", "disable-miss-penalty", Value.newBuilder().setBoolValue(false).build());
38+
CONFIG_MODULE_PROPERTIES.put("combat", "allow-dig-and-use", Value.newBuilder().setBoolValue(false).build());
3839
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-attack.send-packet", Value.newBuilder().setBoolValue(false).build());
3940
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-open.send-packet", Value.newBuilder().setBoolValue(false).build());
4041
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-close.send-packet", Value.newBuilder().setBoolValue(false).build());

docs/developers/modules/combat.mdx

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Callout, Tab, Tabs } from 'nextra-theme-docs'
77
The combat module allows you to modify certain aspects of combat that are usually handled client-sided.
88

99
- Adds the ability to disable the miss penalty, on all versions 1.8 and above.
10+
- Adds the ability to dig and use an item at the same time, like in 1.7, on all versions 1.8 and above.
1011

1112
### Sample Code
1213
Explore each integration by cycling through each tab, to find the best fit for your requirements and needs.
@@ -27,6 +28,14 @@ public void setDisableMissPenalty(boolean value) {
2728
}
2829
```
2930

31+
### Toggle Dig and Use
32+
33+
```java
34+
public void setAllowDigAndUse(boolean value) {
35+
this.combatModule.getOptions().set(CombatModule.ALLOW_DIG_AND_USE, value);
36+
}
37+
```
38+
3039
</Tab>
3140

3241
<Tab>
@@ -35,7 +44,7 @@ public void setDisableMissPenalty(boolean value) {
3544
**Lightweight Protobuf examples.** See [Lightweight Protobuf](/apollo/developers/lightweight/protobuf) for setup.
3645
</Callout>
3746

38-
### Toggle Miss Penalty
47+
**Toggle Miss Penalty**
3948

4049
```java
4150
public void setDisableMissPenalty(boolean value) {
@@ -47,6 +56,18 @@ public void setDisableMissPenalty(boolean value) {
4756
}
4857
```
4958

59+
**Toggle Dig and Use**
60+
61+
```java
62+
public void setAllowDigAndUse(boolean value) {
63+
Map<String, Value> properties = new HashMap<>();
64+
properties.put("allow-dig-and-use", Value.newBuilder().setBoolValue(value).build());
65+
66+
ConfigurableSettings settings = ProtobufPacketUtil.createModuleMessage("combat", properties);
67+
ProtobufPacketUtil.broadcastPacket(settings);
68+
}
69+
```
70+
5071
</Tab>
5172

5273
<Tab>
@@ -55,7 +76,7 @@ public void setDisableMissPenalty(boolean value) {
5576
**Lightweight JSON examples.** See [Lightweight JSON](/apollo/developers/lightweight/json) for setup.
5677
</Callout>
5778

58-
### Toggle Miss Penalty
79+
**Toggle Miss Penalty**
5980

6081
```java
6182
public void setDisableMissPenalty(boolean value) {
@@ -67,14 +88,31 @@ public void setDisableMissPenalty(boolean value) {
6788
}
6889
```
6990

91+
**Toggle Dig and Use**
92+
93+
```java
94+
public void setAllowDigAndUse(boolean value) {
95+
Map<String, Object> properties = new HashMap<>();
96+
properties.put("allow-dig-and-use", value);
97+
98+
JsonObject message = JsonUtil.createEnableModuleObjectWithType("combat", properties);
99+
JsonPacketUtil.broadcastPacket(message);
100+
}
101+
```
102+
70103
</Tab>
71104

72105
</Tabs>
73106

74107
## Available options
75108

76109
- __`DISABLE_MISS_PENALTY`__
77-
- Whether the player gets a hit delay for a missed hit.
110+
- Whether the player gets a hit delay for a missed hit. Enabling this option may cause compatibility issues with anti-cheats.
111+
- Values
112+
- Type: `Boolean`
113+
- Default: `false`
114+
- __`ALLOW_DIG_AND_USE`__
115+
- Whether the player can dig and use an item at the same time, like in 1.7. Applies to all versions 1.8 and above. Enabling this option may cause compatibility issues with anti-cheats.
78116
- Values
79117
- Type: `Boolean`
80118
- Default: `false`

example/bukkit/json/src/main/java/com/lunarclient/apollo/example/json/util/JsonPacketUtil.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public final class JsonPacketUtil {
5353
// While using the Apollo plugin this would be equivalent to modifying the config.yml
5454
CONFIG_MODULE_PROPERTIES.put("colored_fire", "persist-colors-on-unload", false);
5555
CONFIG_MODULE_PROPERTIES.put("combat", "disable-miss-penalty", false);
56+
CONFIG_MODULE_PROPERTIES.put("combat", "allow-dig-and-use", false);
5657
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-attack.send-packet", false);
5758
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-open.send-packet", false);
5859
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-close.send-packet", false);

example/bukkit/proto/src/main/java/com/lunarclient/apollo/example/proto/util/ProtobufPacketUtil.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public final class ProtobufPacketUtil {
5454
// While using the Apollo plugin this would be equivalent to modifying the config.yml
5555
CONFIG_MODULE_PROPERTIES.put("colored_fire", "persist-colors-on-unload", Value.newBuilder().setBoolValue(false).build());
5656
CONFIG_MODULE_PROPERTIES.put("combat", "disable-miss-penalty", Value.newBuilder().setBoolValue(false).build());
57+
CONFIG_MODULE_PROPERTIES.put("combat", "allow-dig-and-use", Value.newBuilder().setBoolValue(false).build());
5758
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-attack.send-packet", Value.newBuilder().setBoolValue(false).build());
5859
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-open.send-packet", Value.newBuilder().setBoolValue(false).build());
5960
CONFIG_MODULE_PROPERTIES.put("packet_enrichment", "player-chat-close.send-packet", Value.newBuilder().setBoolValue(false).build());

0 commit comments

Comments
 (0)