Skip to content

Commit acecf26

Browse files
committed
properly store setting groups and clean up fast break
1 parent 6d170a3 commit acecf26

File tree

12 files changed

+62
-136
lines changed

12 files changed

+62
-136
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ interface ISettingGroup {
2121
val settings: MutableList<AbstractSetting<*>>
2222
}
2323

24-
abstract class SettingGroup() : ISettingGroup {
24+
abstract class SettingGroup(c: Configurable) : ISettingGroup {
2525
override val settings = mutableListOf<AbstractSetting<*>>()
2626

27+
init {
28+
c.settingGroups.add(this)
29+
}
30+
2731
fun <T : Any> AbstractSetting<T>.index(): AbstractSetting<T> {
2832
settings.add(this)
2933
return this

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import java.awt.Color
3333
open class BreakSettings(
3434
c: Configurable,
3535
baseGroup: NamedEnum
36-
) : SettingGroup(), BreakConfig {
36+
) : SettingGroup(c), BreakConfig {
3737
private enum class Group(override val displayName: String) : NamedEnum {
3838
General("General"),
3939
Cosmetic("Cosmetic")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import kotlin.math.max
2626
class BuildSettings(
2727
c: Configurable,
2828
baseGroup: NamedEnum,
29-
) : SettingGroup(), BuildConfig {
29+
) : SettingGroup(c), BuildConfig {
3030
enum class Group(override val displayName: String) : NamedEnum {
3131
General("General"),
3232
Reach("Reach"),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import net.minecraft.item.Items
2626
class EatSettings(
2727
c: Configurable,
2828
baseGroup: NamedEnum
29-
) : SettingGroup(), EatConfig {
29+
) : SettingGroup(c), EatConfig {
3030
val nutritiousFoodDefaults = listOf(Items.APPLE, Items.BAKED_POTATO, Items.BEEF, Items.BEETROOT, Items.BEETROOT_SOUP, Items.BREAD, Items.CARROT, Items.CHICKEN, Items.CHORUS_FRUIT, Items.COD, Items.COOKED_BEEF, Items.COOKED_CHICKEN, Items.COOKED_COD, Items.COOKED_MUTTON, Items.COOKED_PORKCHOP, Items.COOKED_RABBIT, Items.COOKED_SALMON, Items.COOKIE, Items.DRIED_KELP, Items.ENCHANTED_GOLDEN_APPLE, Items.GOLDEN_APPLE, Items.GOLDEN_CARROT, Items.HONEY_BOTTLE, Items.MELON_SLICE, Items.MUSHROOM_STEW, Items.MUTTON, Items.POISONOUS_POTATO, Items.PORKCHOP, Items.POTATO, Items.PUFFERFISH, Items.PUMPKIN_PIE, Items.RABBIT, Items.RABBIT_STEW, Items.ROTTEN_FLESH, Items.SALMON, Items.SPIDER_EYE, Items.SUSPICIOUS_STEW, Items.SWEET_BERRIES, Items.GLOW_BERRIES, Items.TROPICAL_FISH)
3131
val resistanceFoodDefaults = listOf(Items.ENCHANTED_GOLDEN_APPLE)
3232
val regenerationFoodDefaults = listOf(Items.ENCHANTED_GOLDEN_APPLE, Items.GOLDEN_APPLE)

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

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,25 @@ package com.lambda.config.groups
2020
import com.lambda.config.Configurable
2121
import com.lambda.config.SettingGroup
2222
import com.lambda.util.NamedEnum
23-
import com.lambda.util.math.Vec2d
24-
import net.minecraft.util.math.Vec2f
25-
import net.minecraft.util.math.Vec3d
26-
import net.minecraft.util.math.Vec3i
27-
import org.joml.Vector3f
28-
import org.joml.Vector4f
29-
import java.time.LocalDate
30-
import java.time.LocalDateTime
31-
import java.time.ZonedDateTime
3223

3324
class FormatterSettings(
34-
owner: Configurable,
35-
baseGroup: NamedEnum,
36-
) : FormatterConfig, SettingGroup() {
37-
val localeEnum by owner.setting("Locale", FormatterConfig.Locales.US, "The regional formatting used for numbers").group(baseGroup).index()
25+
c: Configurable,
26+
baseGroup: NamedEnum,
27+
) : FormatterConfig, SettingGroup(c) {
28+
val localeEnum by c.setting("Locale", FormatterConfig.Locales.US, "The regional formatting used for numbers").group(baseGroup).index()
3829
override val locale get() = localeEnum.locale
3930

40-
val sep by owner.setting("Separator", FormatterConfig.TupleSeparator.Comma, "Separator for string serialization of tuple data structures").group(baseGroup).index()
41-
val customSep by owner.setting("Custom Separator", "") { sep == FormatterConfig.TupleSeparator.Custom }.group(baseGroup).index()
31+
val sep by c.setting("Separator", FormatterConfig.TupleSeparator.Comma, "Separator for string serialization of tuple data structures").group(baseGroup).index()
32+
val customSep by c.setting("Custom Separator", "") { sep == FormatterConfig.TupleSeparator.Custom }.group(baseGroup).index()
4233
override val separator get() = if (sep == FormatterConfig.TupleSeparator.Custom) customSep else sep.separator
4334

44-
val group by owner.setting("Tuple Prefix", FormatterConfig.TupleGrouping.Parentheses).group(baseGroup).index()
35+
val group by c.setting("Tuple Prefix", FormatterConfig.TupleGrouping.Parentheses).group(baseGroup).index()
4536
override val prefix get() = group.prefix
4637
override val postfix get() = group.postfix
4738

48-
val floatingPrecision by owner.setting("Floating Precision", 3, 0..6, 1, "Precision for floating point numbers").group(baseGroup).index()
39+
val floatingPrecision by c.setting("Floating Precision", 3, 0..6, 1, "Precision for floating point numbers").group(baseGroup).index()
4940
override val precision get() = floatingPrecision
5041

51-
val timeFormat by owner.setting("Time Format", FormatterConfig.Time.IsoDateTime).group(baseGroup).index()
42+
val timeFormat by c.setting("Time Format", FormatterConfig.Time.IsoDateTime).group(baseGroup).index()
5243
override val format get() = timeFormat.format
5344
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import com.lambda.util.NamedEnum
2727
class HotbarSettings(
2828
c: Configurable,
2929
baseGroup: NamedEnum
30-
) : SettingGroup(), HotbarConfig {
30+
) : SettingGroup(c), HotbarConfig {
3131
override val keepTicks by c.setting("Keep Ticks", 1, 0..20, 1, "The number of ticks to keep the current hotbar selection active", " ticks").group(baseGroup).index()
3232
override val swapDelay by c.setting("Swap Delay", 0, 0..3, 1, "The number of ticks delay before allowing another hotbar selection swap", " ticks").group(baseGroup).index()
3333
override val swapsPerTick by c.setting("Swaps Per Tick", 3, 1..10, 1, "The number of hotbar selection swaps that can take place each tick") { swapDelay <= 0 }.group(baseGroup).index()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import com.lambda.util.NamedEnum
2727
class InteractSettings(
2828
c: Configurable,
2929
baseGroup: NamedEnum
30-
) : SettingGroup(), InteractConfig {
30+
) : SettingGroup(c), InteractConfig {
3131
override val rotate by c.setting("Rotate For Interact", true, "Rotates the player to look at the block when interacting").group(baseGroup).index()
3232
override val sorter by c.setting("Interact Sorter", ActionConfig.SortMode.Tool, "The order in which interactions are performed").group(baseGroup).index()
3333
override val swingHand by c.setting("Swing On Interact", true, "Swings the players hand after interacting").group(baseGroup).index()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import com.lambda.util.item.ItemUtils
2727
class InventorySettings(
2828
c: Configurable,
2929
baseGroup: NamedEnum
30-
) : SettingGroup(), InventoryConfig {
30+
) : SettingGroup(c), InventoryConfig {
3131
enum class Group(override val displayName: String) : NamedEnum {
3232
General("General"),
3333
Container("Container"),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import com.lambda.util.NamedEnum
2929
class PlaceSettings(
3030
c: Configurable,
3131
baseGroup: NamedEnum
32-
) : SettingGroup(), PlaceConfig {
32+
) : SettingGroup(c), PlaceConfig {
3333
override val rotateForPlace by c.setting("Rotate For Place", true, "Rotate towards block while placing").group(baseGroup).index()
3434
override val airPlace by c.setting("Air Place", AirPlaceMode.None, "Allows for placing blocks without adjacent faces").group(baseGroup).index()
3535
override val axisRotateSetting by c.setting("Axis Rotate", true, "Overrides the Rotate For Place setting and rotates the player on each axis to air place rotational blocks") { airPlace.isEnabled }.group(baseGroup).index()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import kotlin.random.Random
3434
class RotationSettings(
3535
c: Configurable,
3636
baseGroup: NamedEnum,
37-
) : SettingGroup(), RotationConfig {
37+
) : SettingGroup(c), RotationConfig {
3838
override var rotationMode by c.setting("Mode", RotationMode.Sync, "How the player is being rotated on interaction").group(baseGroup).index()
3939

4040
/** How many ticks to keep the rotation before resetting */

0 commit comments

Comments
 (0)