Skip to content

Commit d7b85d2

Browse files
committed
back to setDefaultAutomationConfig instead of overriding the default
1 parent b72f40e commit d7b85d2

File tree

10 files changed

+116
-111
lines changed

10 files changed

+116
-111
lines changed

src/main/kotlin/com/lambda/config/AutomationConfig.kt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,20 @@ open class AutomationConfig(
6262
val hiddenSettings = mutableSetOf<AbstractSetting<*>>()
6363

6464
companion object {
65-
fun Module.automationConfig(
66-
name: String = this.name,
65+
context(module: Module)
66+
fun MutableAutomationConfig.setDefaultAutomationConfig(
67+
name: String = module.name,
6768
edits: (AutomationConfig.() -> Unit)? = null
68-
) = AutomationConfig("$name Automation Config").apply { edits?.invoke(this) }
69+
) {
70+
defaultAutomationConfig = AutomationConfig("$name Automation Config").apply { edits?.invoke(this) }
71+
}
6972

70-
fun automationConfig(
73+
fun MutableAutomationConfig.setDefaultAutomationConfig(
7174
name: String,
7275
edits: (AutomationConfig.() -> Unit)? = null
73-
) = AutomationConfig("$name Automation Config").apply { edits?.invoke(this) }
76+
) {
77+
defaultAutomationConfig = AutomationConfig("$name Automation Config").apply { edits?.invoke(this) }
78+
}
7479

7580
object DEFAULT : AutomationConfig("Default") {
7681
val renders by setting("Render", false).group(Group.Render)

src/main/kotlin/com/lambda/module/Module.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ abstract class Module(
121121
defaultKeybind: Bind = Bind.EMPTY,
122122
autoDisable: Boolean = false
123123
) : Nameable, Muteable, Configurable(ModuleConfigs), MutableAutomationConfig {
124-
override var defaultAutomationConfig: AutomationConfig = AutomationConfig.Companion.DEFAULT
124+
final override var defaultAutomationConfig: AutomationConfig = AutomationConfig.Companion.DEFAULT
125125
set(value) {
126126
field = value
127127
automationConfig = value

src/main/kotlin/com/lambda/module/modules/movement/BetterFirework.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package com.lambda.module.modules.movement
1919

20-
import com.lambda.config.AutomationConfig.Companion.automationConfig
20+
import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig
2121
import com.lambda.config.applyEdits
2222
import com.lambda.config.settings.complex.Bind
2323
import com.lambda.context.SafeContext
@@ -57,14 +57,6 @@ object BetterFirework : Module(
5757
private var clientSwing by setting("Swing", true, "Swing hand client side")
5858
private var invUse by setting("Inventory", true, "Use fireworks from inventory") { activateButton.key != KeyCode.Unbound.code }
5959

60-
override var defaultAutomationConfig = automationConfig {
61-
applyEdits {
62-
hideAllGroupsExcept(hotbarConfig, inventoryConfig)
63-
hotbarConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) }
64-
inventoryConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) }
65-
}
66-
}
67-
6860
private var takeoffState = TakeoffState.None
6961

7062
val ClientPlayerEntity.canTakeoff: Boolean
@@ -74,6 +66,14 @@ object BetterFirework : Module(
7466
get() = !abilities.flying && !isClimbing && !isGliding && !isTouchingWater && !isOnGround && !hasVehicle() && !hasStatusEffect(StatusEffects.LEVITATION)
7567

7668
init {
69+
setDefaultAutomationConfig {
70+
applyEdits {
71+
hideAllGroupsExcept(hotbarConfig, inventoryConfig)
72+
hotbarConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) }
73+
inventoryConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Pre)) }
74+
}
75+
}
76+
7777
listen<TickEvent.Pre> {
7878
when (takeoffState) {
7979
TakeoffState.None -> {}

src/main/kotlin/com/lambda/module/modules/player/AutoEat.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package com.lambda.module.modules.player
1919

20-
import com.lambda.config.AutomationConfig.Companion.automationConfig
20+
import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig
2121
import com.lambda.config.applyEdits
2222
import com.lambda.config.groups.EatConfig.Companion.reasonEating
2323
import com.lambda.event.events.TickEvent
@@ -34,15 +34,15 @@ object AutoEat : Module(
3434
description = "Eats food when you are hungry",
3535
tag = ModuleTag.PLAYER,
3636
) {
37-
override var defaultAutomationConfig = automationConfig {
38-
applyEdits {
39-
hideAllGroupsExcept(eatConfig)
40-
}
41-
}
42-
4337
private var eatTask: EatTask? = null
4438

4539
init {
40+
setDefaultAutomationConfig {
41+
applyEdits {
42+
hideAllGroupsExcept(eatConfig)
43+
}
44+
}
45+
4646
listen<TickEvent.Pre> {
4747
val reason = runSafeAutomated { reasonEating() }
4848
if (eatTask != null || !reason.shouldEat()) return@listen

src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package com.lambda.module.modules.player
1919

20-
import com.lambda.config.AutomationConfig.Companion.automationConfig
20+
import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig
2121
import com.lambda.config.applyEdits
2222
import com.lambda.event.events.PlayerEvent
2323
import com.lambda.event.events.TickEvent
@@ -37,43 +37,43 @@ object FastBreak : Module(
3737
description = "Break blocks faster.",
3838
tag = ModuleTag.PLAYER,
3939
) {
40-
override var defaultAutomationConfig = automationConfig {
41-
applyEdits {
42-
hideAllGroupsExcept(breakConfig, rotationConfig, hotbarConfig)
43-
buildConfig.apply {
44-
editTyped(
45-
::pathing,
46-
::stayInRange,
47-
::useDefaultReach,
48-
::checkSideVisibility,
49-
::strictRayCast
50-
) { defaultValue(false) }
51-
::interactionsPerTick.edit { defaultValue(1) }
52-
::interactReach.edit { defaultValue(Double.MAX_VALUE) }
53-
}
54-
breakConfig.apply {
55-
editTyped(
56-
::avoidLiquids,
57-
::avoidSupporting,
58-
::efficientOnly,
59-
::suitableToolsOnly
60-
) { defaultValue(false) }
61-
editTyped(
62-
::rotateForBreak,
63-
::doubleBreak
64-
) { defaultValue(false); hide() }
65-
::breaksPerTick.edit { defaultValue(1); hide() }
66-
::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Input.Post)); hide() }
67-
::maxPendingBreaks.edit { defaultValue(Int.MAX_VALUE); hide() }
68-
hide(::sorter, ::unsafeCancels)
69-
}
70-
hotbarConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Input.Post)); hide() }
71-
}
72-
}
73-
7440
private val pendingInteractions = ConcurrentLinkedQueue<BuildContext>()
7541

7642
init {
43+
setDefaultAutomationConfig {
44+
applyEdits {
45+
hideAllGroupsExcept(breakConfig, rotationConfig, hotbarConfig)
46+
buildConfig.apply {
47+
editTyped(
48+
::pathing,
49+
::stayInRange,
50+
::useDefaultReach,
51+
::checkSideVisibility,
52+
::strictRayCast
53+
) { defaultValue(false) }
54+
::interactionsPerTick.edit { defaultValue(1) }
55+
::interactReach.edit { defaultValue(Double.MAX_VALUE) }
56+
}
57+
breakConfig.apply {
58+
editTyped(
59+
::avoidLiquids,
60+
::avoidSupporting,
61+
::efficientOnly,
62+
::suitableToolsOnly
63+
) { defaultValue(false) }
64+
editTyped(
65+
::rotateForBreak,
66+
::doubleBreak
67+
) { defaultValue(false); hide() }
68+
::breaksPerTick.edit { defaultValue(1); hide() }
69+
::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Input.Post)); hide() }
70+
::maxPendingBreaks.edit { defaultValue(Int.MAX_VALUE); hide() }
71+
hide(::sorter, ::unsafeCancels)
72+
}
73+
hotbarConfig::tickStageMask.edit { defaultValue(mutableSetOf(TickEvent.Input.Post)); hide() }
74+
}
75+
}
76+
7777
listen<PlayerEvent.Attack.Block> { it.cancel() }
7878
listen<PlayerEvent.Breaking.Update> { event ->
7979
event.cancel()

src/main/kotlin/com/lambda/module/modules/player/HighwayTools.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package com.lambda.module.modules.player
1919

20-
import com.lambda.config.AutomationConfig.Companion.automationConfig
20+
import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig
2121
import com.lambda.config.applyEdits
2222
import com.lambda.interaction.BaritoneManager
2323
import com.lambda.interaction.construction.blueprint.Blueprint.Companion.emptyStructure
@@ -65,12 +65,6 @@ object HighwayTools : Module(
6565
private val distance by setting("Distance", -1, -1..1000000, 1, "Distance to build the highway/tunnel (negative for infinite)")
6666
private val sliceSize by setting("Slice Size", 3, 1..5, 1, "Number of slices to build at once")
6767

68-
override var defaultAutomationConfig = automationConfig {
69-
applyEdits {
70-
hideGroup(interactConfig)
71-
}
72-
}
73-
7468
private var octant = EightWayDirection.NORTH
7569
private var distanceMoved = 0
7670
private var startPos = BlockPos.ORIGIN
@@ -95,6 +89,12 @@ object HighwayTools : Module(
9589
}
9690

9791
init {
92+
setDefaultAutomationConfig {
93+
applyEdits {
94+
hideGroup(interactConfig)
95+
}
96+
}
97+
9898
onEnable {
9999
octant = player.octant
100100
startPos = player.blockPos

src/main/kotlin/com/lambda/module/modules/player/Nuker.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package com.lambda.module.modules.player
1919

20-
import com.lambda.config.AutomationConfig.Companion.automationConfig
20+
import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig
2121
import com.lambda.config.applyEdits
2222
import com.lambda.interaction.BaritoneManager
2323
import com.lambda.interaction.construction.blueprint.TickingBlueprint.Companion.tickingBlueprint
@@ -44,15 +44,15 @@ object Nuker : Module(
4444
private val fillFloor by setting("Fill Floor", false)
4545
private val baritoneSelection by setting("Baritone Selection", false, "Restricts nuker to your baritone selection")
4646

47-
override var defaultAutomationConfig = automationConfig {
48-
applyEdits {
49-
hideGroup(interactConfig)
50-
}
51-
}
52-
5347
private var task: Task<*>? = null
5448

5549
init {
50+
setDefaultAutomationConfig {
51+
applyEdits {
52+
hideGroup(interactConfig)
53+
}
54+
}
55+
5656
onEnable {
5757
task = tickingBlueprint {
5858
if (onGround && !player.isOnGround) return@tickingBlueprint emptyMap()

src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package com.lambda.module.modules.player
1919

20-
import com.lambda.config.AutomationConfig.Companion.automationConfig
20+
import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig
2121
import com.lambda.config.applyEdits
2222
import com.lambda.context.SafeContext
2323
import com.lambda.event.events.PlayerEvent
@@ -72,24 +72,6 @@ object PacketMine : Module(
7272
private val startColor by setting("Start Color", Color(255, 255, 0, 60), "The color of the start (closest to breaking) of the queue") { renderQueue && dynamicColor }.group(Group.Renders)
7373
private val endColor by setting("End Color", Color(255, 0, 0, 60), "The color of the end (farthest from breaking) of the queue") { renderQueue && dynamicColor }.group(Group.Renders)
7474

75-
override var defaultAutomationConfig = automationConfig {
76-
applyEdits {
77-
breakConfig.apply {
78-
editTyped(
79-
::avoidLiquids,
80-
::avoidSupporting,
81-
::efficientOnly,
82-
::suitableToolsOnly
83-
) { defaultValue(false) }
84-
::swing.edit { defaultValue(BreakConfig.SwingMode.Start) }
85-
}
86-
hotbarConfig.apply {
87-
::keepTicks.edit { defaultValue(0) }
88-
}
89-
hideGroups(buildConfig, placeConfig, interactConfig, inventoryConfig, eatConfig)
90-
}
91-
}
92-
9375
private val pendingInteractions = ConcurrentLinkedQueue<BuildContext>()
9476

9577
private var breaks = 0
@@ -115,6 +97,24 @@ object PacketMine : Module(
11597
private var attackedThisTick = false
11698

11799
init {
100+
setDefaultAutomationConfig {
101+
applyEdits {
102+
breakConfig.apply {
103+
editTyped(
104+
::avoidLiquids,
105+
::avoidSupporting,
106+
::efficientOnly,
107+
::suitableToolsOnly
108+
) { defaultValue(false) }
109+
::swing.edit { defaultValue(BreakConfig.SwingMode.Start) }
110+
}
111+
hotbarConfig.apply {
112+
::keepTicks.edit { defaultValue(0) }
113+
}
114+
hideGroups(buildConfig, placeConfig, interactConfig, inventoryConfig, eatConfig)
115+
}
116+
}
117+
118118
listen<TickEvent.Post> {
119119
attackedThisTick = false
120120
}

src/main/kotlin/com/lambda/module/modules/player/Printer.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package com.lambda.module.modules.player
1919

20-
import com.lambda.config.AutomationConfig.Companion.automationConfig
20+
import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig
2121
import com.lambda.config.applyEdits
2222
import com.lambda.interaction.construction.blueprint.TickingBlueprint
2323
import com.lambda.interaction.construction.verify.TargetState
@@ -45,17 +45,17 @@ object Printer : Module(
4545
private val range by setting("Range", 5, 1..7, 1)
4646
private val air by setting("Air", false)
4747

48-
override var defaultAutomationConfig = automationConfig {
49-
applyEdits {
50-
editTyped(buildConfig::pathing, buildConfig::stayInRange) { defaultValue(false) }
51-
editTyped(breakConfig::efficientOnly, breakConfig::suitableToolsOnly) { defaultValue(false) }
52-
placeConfig::airPlace.edit { defaultValue(PlaceConfig.AirPlaceMode.Grim) }
53-
}
54-
}
55-
5648
private var buildTask: Task<*>? = null
5749

5850
init {
51+
setDefaultAutomationConfig {
52+
applyEdits {
53+
editTyped(buildConfig::pathing, buildConfig::stayInRange) { defaultValue(false) }
54+
editTyped(breakConfig::efficientOnly, breakConfig::suitableToolsOnly) { defaultValue(false) }
55+
placeConfig::airPlace.edit { defaultValue(PlaceConfig.AirPlaceMode.Grim) }
56+
}
57+
}
58+
5959
onEnable {
6060
if (!isLitematicaAvailable()) {
6161
error("Litematica is not installed!")

src/main/kotlin/com/lambda/module/modules/player/Scaffold.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package com.lambda.module.modules.player
1919

20-
import com.lambda.config.AutomationConfig.Companion.automationConfig
20+
import com.lambda.config.AutomationConfig.Companion.setDefaultAutomationConfig
2121
import com.lambda.config.applyEdits
2222
import com.lambda.config.settings.complex.Bind
2323
import com.lambda.context.SafeContext
@@ -50,21 +50,21 @@ object Scaffold : Module(
5050
private val descend by setting("Descend", KeyCode.Unbound, "Lower the place position by one to allow the player to lower y level")
5151
private val descendAmount by setting("Descend Amount", 1, 1..5, 1, "The amount to lower the place position by when descending", unit = " blocks") { descend != Bind.EMPTY }
5252

53-
override var defaultAutomationConfig = automationConfig {
54-
applyEdits {
55-
buildConfig.apply {
56-
editTyped(::pathing, ::stayInRange, ::collectDrops) {
57-
defaultValue(false)
58-
hide()
53+
private val pendingActions = ConcurrentLinkedQueue<BuildContext>()
54+
55+
init {
56+
setDefaultAutomationConfig {
57+
applyEdits {
58+
buildConfig.apply {
59+
editTyped(::pathing, ::stayInRange, ::collectDrops) {
60+
defaultValue(false)
61+
hide()
62+
}
5963
}
64+
hideAllGroupsExcept(placeConfig, rotationConfig, hotbarConfig)
6065
}
61-
hideAllGroupsExcept(placeConfig, rotationConfig, hotbarConfig)
6266
}
63-
}
6467

65-
private val pendingActions = ConcurrentLinkedQueue<BuildContext>()
66-
67-
init {
6868
listen<TickEvent.Pre> {
6969
val playerSupport = player.blockPos.down()
7070
val alreadySupported = blockState(playerSupport).hasSolidTopSurface(world, playerSupport, player)

0 commit comments

Comments
 (0)