Skip to content

Commit 8734884

Browse files
committed
Fixed grouping
1 parent adfbb46 commit 8734884

File tree

8 files changed

+93
-92
lines changed

8 files changed

+93
-92
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ abstract class AbstractSetting<T : Any>(
150150
listeners.add(ValueListener(false, block))
151151
}
152152

153+
fun group(path: List<NamedEnum>, vararg continuation: NamedEnum) = apply {
154+
groups.add(path + continuation)
155+
}
156+
153157
fun group(vararg path: NamedEnum) = apply {
154158
groups.add(path.toList())
155159
}

src/main/kotlin/com/lambda/config/groups/BreakSettings.kt

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -31,77 +31,77 @@ import java.awt.Color
3131

3232
class BreakSettings(
3333
c: Configurable,
34-
baseGroup: NamedEnum,
35-
vis: () -> Boolean = { true }
34+
groupPath: List<NamedEnum> = emptyList(),
35+
vis: () -> Boolean = { true },
3636
) : BreakConfig {
3737
enum class Group(override val displayName: String) : NamedEnum {
3838
General("General"),
3939
Cosmetic("Cosmetic")
4040
}
4141

4242
// General
43-
override val breakMode by c.setting("Break Mode", BreakMode.Packet, visibility = vis).group(baseGroup, Group.General)
44-
override val sorter by c.setting("Sorter", SortMode.Closest, "The order in which breaks are performed", visibility = vis).group(baseGroup, Group.General)
45-
override val reBreak by c.setting("ReBreak", true, "Re-breaks blocks after they've been broken once", visibility = vis).group(baseGroup, Group.General)
43+
override val breakMode by c.setting("Break Mode", BreakMode.Packet, visibility = vis).group(groupPath, Group.General)
44+
override val sorter by c.setting("Sorter", SortMode.Closest, "The order in which breaks are performed", visibility = vis).group(groupPath, Group.General)
45+
override val reBreak by c.setting("ReBreak", true, "Re-breaks blocks after they've been broken once", visibility = vis).group(groupPath, Group.General)
4646

4747
// Double break
48-
override val doubleBreak by c.setting("Double Break", true, "Allows breaking two blocks at once", visibility = vis).group(baseGroup, Group.General)
49-
override val unsafeCancels by c.setting("Unsafe Cancels", true, "Allows cancelling block breaking even if the server might continue breaking sever side, potentially causing unexpected state changes", visibility = vis).group(baseGroup, Group.General)
48+
override val doubleBreak by c.setting("Double Break", true, "Allows breaking two blocks at once", visibility = vis).group(groupPath, Group.General)
49+
override val unsafeCancels by c.setting("Unsafe Cancels", true, "Allows cancelling block breaking even if the server might continue breaking sever side, potentially causing unexpected state changes", visibility = vis).group(groupPath, Group.General)
5050

5151
// Fixes / Delays
52-
override val breakThreshold by c.setting("Break Threshold", 0.70f, 0.1f..1.0f, 0.01f, "The break amount at which the block is considered broken", visibility = vis).group(baseGroup, Group.General)
53-
override val fudgeFactor by c.setting("Fudge Factor", 2, 0..5, 1, "The amount of ticks to give double, aka secondary breaks extra for the server to recognise the break", visibility = vis).group(baseGroup, Group.General)
52+
override val breakThreshold by c.setting("Break Threshold", 0.70f, 0.1f..1.0f, 0.01f, "The break amount at which the block is considered broken", visibility = vis).group(groupPath, Group.General)
53+
override val fudgeFactor by c.setting("Fudge Factor", 2, 0..5, 1, "The amount of ticks to give double, aka secondary breaks extra for the server to recognise the break", visibility = vis).group(groupPath, Group.General)
5454
// override val desyncFix by c.setting("Desync Fix", false, "Predicts if the players breaking will be slowed next tick as block break packets are processed using the players next position") { vis() && page == Page.General }
55-
override val breakDelay by c.setting("Break Delay", 0, 0..6, 1, "The delay between breaking blocks", " ticks", visibility = vis).group(baseGroup, Group.General)
55+
override val breakDelay by c.setting("Break Delay", 0, 0..6, 1, "The delay between breaking blocks", " ticks", visibility = vis).group(groupPath, Group.General)
5656

5757
// Timing
58-
override val breakStageMask by c.setting("Break Stage Mask", setOf(TickEvent.Input.Post, TickEvent.Player.Post), description = "The sub-tick timing at which break actions can be performed", visibility = vis).group(baseGroup, Group.General)
58+
override val breakStageMask by c.setting("Break Stage Mask", setOf(TickEvent.Input.Post, TickEvent.Player.Post), description = "The sub-tick timing at which break actions can be performed", visibility = vis).group(groupPath, Group.General)
5959

6060
// Swap
61-
override val swapMode by c.setting("Swap Mode", BreakConfig.SwapMode.End, "Decides when to swap to the best suited tool when breaking a block", visibility = vis).group(baseGroup, Group.General)
61+
override val swapMode by c.setting("Swap Mode", BreakConfig.SwapMode.End, "Decides when to swap to the best suited tool when breaking a block", visibility = vis).group(groupPath, Group.General)
6262

6363
// Swing
64-
override val swing by c.setting("Swing Mode", SwingMode.Constant, "The times at which to swing the players hand", visibility = vis).group(baseGroup, Group.General)
65-
override val swingType by c.setting("Break Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { vis() && swing != SwingMode.None }.group(baseGroup, Group.General)
64+
override val swing by c.setting("Swing Mode", SwingMode.Constant, "The times at which to swing the players hand", visibility = vis).group(groupPath, Group.General)
65+
override val swingType by c.setting("Break Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { vis() && swing != SwingMode.None }.group(groupPath, Group.General)
6666

6767
// Rotate
68-
override val rotateForBreak by c.setting("Rotate For Break", false, "Rotate towards block while breaking", visibility = vis).group(baseGroup, Group.General)
68+
override val rotateForBreak by c.setting("Rotate For Break", false, "Rotate towards block while breaking", visibility = vis).group(groupPath, Group.General)
6969

7070
// Pending / Post
71-
override val breakConfirmation by c.setting("Break Confirmation", BreakConfirmationMode.BreakThenAwait, "The style of confirmation used when breaking", visibility = vis).group(baseGroup, Group.General)
72-
override val breaksPerTick by c.setting("Breaks Per Tick", 5, 1..30, 1, "Maximum instant block breaks per tick", visibility = vis).group(baseGroup, Group.General)
73-
override val maxPendingBreaks by c.setting("Max Pending Breaks", 15, 1..30, 1, "The maximum amount of pending breaks", visibility = vis).group(baseGroup, Group.General)
71+
override val breakConfirmation by c.setting("Break Confirmation", BreakConfirmationMode.BreakThenAwait, "The style of confirmation used when breaking", visibility = vis).group(groupPath, Group.General)
72+
override val breaksPerTick by c.setting("Breaks Per Tick", 5, 1..30, 1, "Maximum instant block breaks per tick", visibility = vis).group(groupPath, Group.General)
73+
override val maxPendingBreaks by c.setting("Max Pending Breaks", 15, 1..30, 1, "The maximum amount of pending breaks", visibility = vis).group(groupPath, Group.General)
7474

7575
// Block
76-
override val avoidLiquids by c.setting("Avoid Liquids", true, "Avoids breaking blocks that would cause liquid to spill", visibility = vis).group(baseGroup, Group.General)
77-
override val avoidSupporting by c.setting("Avoid Supporting", true, "Avoids breaking the block supporting the player", visibility = vis).group(baseGroup, Group.General)
78-
override val breakWeakBlocks by c.setting("Break Weak Blocks", false, "Break blocks that dont have structural integrity (e.g: grass)", visibility = vis).group(baseGroup, Group.General)
79-
override val ignoredBlocks by c.setting("Ignored Blocks", allSigns, description = "Blocks that wont be broken", visibility = vis).group(baseGroup, Group.General)
76+
override val avoidLiquids by c.setting("Avoid Liquids", true, "Avoids breaking blocks that would cause liquid to spill", visibility = vis).group(groupPath, Group.General)
77+
override val avoidSupporting by c.setting("Avoid Supporting", true, "Avoids breaking the block supporting the player", visibility = vis).group(groupPath, Group.General)
78+
override val breakWeakBlocks by c.setting("Break Weak Blocks", false, "Break blocks that dont have structural integrity (e.g: grass)", visibility = vis).group(groupPath, Group.General)
79+
override val ignoredBlocks by c.setting("Ignored Blocks", allSigns, description = "Blocks that wont be broken", visibility = vis).group(groupPath, Group.General)
8080

8181
// Tool
82-
override val suitableToolsOnly by c.setting("Suitable Tools Only", false, "Places a restriction to only use tools suitable for the given block", visibility = vis).group(baseGroup, Group.General)
83-
override val forceSilkTouch by c.setting("Force Silk Touch", false, "Force silk touch when breaking blocks", visibility = vis).group(baseGroup, Group.General)
84-
override val forceFortunePickaxe by c.setting("Force Fortune Pickaxe", false, "Force fortune pickaxe when breaking blocks", visibility = vis).group(baseGroup, Group.General)
85-
override val minFortuneLevel by c.setting("Min Fortune Level", 1, 1..3, 1, "The minimum fortune level to use") { vis() && forceFortunePickaxe }.group(baseGroup, Group.General)
82+
override val suitableToolsOnly by c.setting("Suitable Tools Only", false, "Places a restriction to only use tools suitable for the given block", visibility = vis).group(groupPath, Group.General)
83+
override val forceSilkTouch by c.setting("Force Silk Touch", false, "Force silk touch when breaking blocks", visibility = vis).group(groupPath, Group.General)
84+
override val forceFortunePickaxe by c.setting("Force Fortune Pickaxe", false, "Force fortune pickaxe when breaking blocks", visibility = vis).group(groupPath, Group.General)
85+
override val minFortuneLevel by c.setting("Min Fortune Level", 1, 1..3, 1, "The minimum fortune level to use") { vis() && forceFortunePickaxe }.group(groupPath, Group.General)
8686

8787
// Cosmetics
88-
override val sounds by c.setting("Break Sounds", true, "Plays the breaking sounds", visibility = vis).group(baseGroup, Group.Cosmetic)
89-
override val particles by c.setting("Particles", true, "Renders the breaking particles", visibility = vis).group(baseGroup, Group.Cosmetic)
90-
override val breakingTexture by c.setting("Breaking Overlay", true, "Overlays the breaking texture at its different stages", visibility = vis).group(baseGroup, Group.Cosmetic)
88+
override val sounds by c.setting("Break Sounds", true, "Plays the breaking sounds", visibility = vis).group(groupPath, Group.Cosmetic)
89+
override val particles by c.setting("Particles", true, "Renders the breaking particles", visibility = vis).group(groupPath, Group.Cosmetic)
90+
override val breakingTexture by c.setting("Breaking Overlay", true, "Overlays the breaking texture at its different stages", visibility = vis).group(groupPath, Group.Cosmetic)
9191
// Modes
92-
override val renders by c.setting("Renders", true, "Enables the render settings for breaking progress", visibility = vis).group(baseGroup, Group.Cosmetic)
93-
override val animation by c.setting("Animation", AnimationMode.Out, "The style of animation used for the box") { vis() && renders }.group(baseGroup, Group.Cosmetic)
92+
override val renders by c.setting("Renders", true, "Enables the render settings for breaking progress", visibility = vis).group(groupPath, Group.Cosmetic)
93+
override val animation by c.setting("Animation", AnimationMode.Out, "The style of animation used for the box") { vis() && renders }.group(groupPath, Group.Cosmetic)
9494
// Fill
95-
override val fill by c.setting("Fill", true, "Renders the sides of the box to display break progress") { vis() && renders }.group(baseGroup, Group.Cosmetic)
96-
override val dynamicFillColor by c.setting("Dynamic Colour", true, "Enables fill color interpolation from start to finish for fill when breaking a block") { vis() && renders && fill }.group(baseGroup, Group.Cosmetic)
97-
override val staticFillColor by c.setting("Fill Color", Color(255, 0, 0, 60).brighter(), "The color of the fill") { vis() && renders && !dynamicFillColor && fill }.group(baseGroup, Group.Cosmetic)
98-
override val startFillColor by c.setting("Start Fill Color", Color(255, 0, 0, 60).brighter(), "The color of the fill at the start of breaking") { vis() && renders && dynamicFillColor && fill }.group(baseGroup, Group.Cosmetic)
99-
override val endFillColor by c.setting("End Fill Color", Color(0, 255, 0, 60).brighter(), "The color of the fill at the end of breaking") { vis() && renders && dynamicFillColor && fill }.group(baseGroup, Group.Cosmetic)
95+
override val fill by c.setting("Fill", true, "Renders the sides of the box to display break progress") { vis() && renders }.group(groupPath, Group.Cosmetic)
96+
override val dynamicFillColor by c.setting("Dynamic Colour", true, "Enables fill color interpolation from start to finish for fill when breaking a block") { vis() && renders && fill }.group(groupPath, Group.Cosmetic)
97+
override val staticFillColor by c.setting("Fill Color", Color(255, 0, 0, 60).brighter(), "The color of the fill") { vis() && renders && !dynamicFillColor && fill }.group(groupPath, Group.Cosmetic)
98+
override val startFillColor by c.setting("Start Fill Color", Color(255, 0, 0, 60).brighter(), "The color of the fill at the start of breaking") { vis() && renders && dynamicFillColor && fill }.group(groupPath, Group.Cosmetic)
99+
override val endFillColor by c.setting("End Fill Color", Color(0, 255, 0, 60).brighter(), "The color of the fill at the end of breaking") { vis() && renders && dynamicFillColor && fill }.group(groupPath, Group.Cosmetic)
100100
// Outline
101-
override val outline by c.setting("Outline", true, "Renders the lines of the box to display break progress") { vis() && renders }.group(baseGroup, Group.Cosmetic)
102-
override val outlineWidth by c.setting("Outline Width", 2, 0..5, 1, "The width of the outline") { vis() && renders && outline }.group(baseGroup, Group.Cosmetic)
103-
override val dynamicOutlineColor by c.setting("Dynamic Outline Color", true, "Enables color interpolation from start to finish for the outline when breaking a block") { vis() && renders && outline }.group(baseGroup, Group.Cosmetic)
104-
override val staticOutlineColor by c.setting("Outline Color", Color.RED.brighter(), "The Color of the outline at the start of breaking") { vis() && renders && !dynamicOutlineColor && outline }.group(baseGroup, Group.Cosmetic)
105-
override val startOutlineColor by c.setting("Start Outline Color", Color.RED.brighter(), "The color of the outline at the start of breaking") { vis() && renders && dynamicOutlineColor && outline }.group(baseGroup, Group.Cosmetic)
106-
override val endOutlineColor by c.setting("End Outline Color", Color.GREEN.brighter(), "The color of the outline at the end of breaking") { vis() && renders && dynamicOutlineColor && outline }.group(baseGroup, Group.Cosmetic)
101+
override val outline by c.setting("Outline", true, "Renders the lines of the box to display break progress") { vis() && renders }.group(groupPath, Group.Cosmetic)
102+
override val outlineWidth by c.setting("Outline Width", 2, 0..5, 1, "The width of the outline") { vis() && renders && outline }.group(groupPath, Group.Cosmetic)
103+
override val dynamicOutlineColor by c.setting("Dynamic Outline Color", true, "Enables color interpolation from start to finish for the outline when breaking a block") { vis() && renders && outline }.group(groupPath, Group.Cosmetic)
104+
override val staticOutlineColor by c.setting("Outline Color", Color.RED.brighter(), "The Color of the outline at the start of breaking") { vis() && renders && !dynamicOutlineColor && outline }.group(groupPath, Group.Cosmetic)
105+
override val startOutlineColor by c.setting("Start Outline Color", Color.RED.brighter(), "The color of the outline at the start of breaking") { vis() && renders && dynamicOutlineColor && outline }.group(groupPath, Group.Cosmetic)
106+
override val endOutlineColor by c.setting("End Outline Color", Color.GREEN.brighter(), "The color of the outline at the end of breaking") { vis() && renders && dynamicOutlineColor && outline }.group(groupPath, Group.Cosmetic)
107107
}

src/main/kotlin/com/lambda/config/groups/BuildSettings.kt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import com.lambda.interaction.request.placing.PlaceConfig
2424

2525
class BuildSettings(
2626
c: Configurable,
27-
baseGroup: NamedEnum,
28-
vis: () -> Boolean = { true }
27+
vararg groupPath: NamedEnum,
28+
vis: () -> Boolean = { true },
2929
) : BuildConfig {
3030
enum class Group(override val displayName: String) : NamedEnum {
3131
General("General"),
@@ -35,24 +35,24 @@ class BuildSettings(
3535
}
3636

3737
// General
38-
override val pathing by c.setting("Pathing", true, "Path to blocks", vis).group(baseGroup, Group.General)
39-
override val stayInRange by c.setting("Stay In Range", true, "Stay in range of blocks", vis).group(baseGroup, Group.General)
40-
override val collectDrops by c.setting("Collect All Drops", false, "Collect all drops when breaking blocks", vis).group(baseGroup, Group.General)
41-
override val interactionsPerTick by c.setting("Interactions Per Tick", 5, 1..30, 1, "The amount of interactions that can happen per tick", visibility = vis).group(baseGroup, Group.General)
42-
override val maxPendingInteractions by c.setting("Max Pending Interactions", 1, 1..10, 1, "Dont wait for this many interactions for the server response", visibility = vis).group(baseGroup, Group.General)
38+
override val pathing by c.setting("Pathing", true, "Path to blocks", vis).group(*groupPath, Group.General)
39+
override val stayInRange by c.setting("Stay In Range", true, "Stay in range of blocks", vis).group(*groupPath, Group.General)
40+
override val collectDrops by c.setting("Collect All Drops", false, "Collect all drops when breaking blocks", vis).group(*groupPath, Group.General)
41+
override val interactionsPerTick by c.setting("Interactions Per Tick", 5, 1..30, 1, "The amount of interactions that can happen per tick", visibility = vis).group(*groupPath, Group.General)
42+
override val maxPendingInteractions by c.setting("Max Pending Interactions", 1, 1..10, 1, "Dont wait for this many interactions for the server response", visibility = vis).group(*groupPath, Group.General)
4343

4444
// Breaking
45-
override val breaking = BreakSettings(c, Group.Break, vis)
45+
override val breaking = BreakSettings(c, groupPath.toList() + Group.Break, vis)
4646

4747
// Placing
48-
override val placing = PlaceSettings(c, Group.Place, vis)
48+
override val placing = PlaceSettings(c, groupPath.toList() + Group.Place, vis)
4949

5050
//Interacting
51-
override val interacting = InteractSettings(c, Group.Interact, vis)
51+
override val interacting = InteractSettings(c, groupPath.toList() + Group.Interact, vis)
5252

5353
override val interactionTimeout by c.setting("Interaction Timeout", 10, 1..30, 1, "Timeout for block breaks in ticks", unit = " ticks") {
5454
vis() && (placing.placeConfirmationMode != PlaceConfig.PlaceConfirmationMode.None
5555
|| breaking.breakConfirmation != BreakConfirmationMode.None
5656
|| interacting.interactConfirmationMode != InteractionConfig.InteractConfirmationMode.None)
57-
}.group(baseGroup, Group.Break, Group.Place, Group.Interact)
57+
}.group(*groupPath, Group.Break).group(*groupPath, Group.Place).group(*groupPath, Group.Interact)
5858
}

0 commit comments

Comments
 (0)