Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/main/kotlin/com/lambda/config/AbstractSetting.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.lambda.context.SafeContext
import com.lambda.gui.Layout
import com.lambda.threading.runSafe
import com.lambda.util.Communication.info
import com.lambda.util.Describable
import com.lambda.util.Nameable
import com.lambda.util.NamedEnum
import com.lambda.util.extension.CommandBuilder
Expand Down Expand Up @@ -94,13 +95,14 @@ import kotlin.reflect.KProperty
* @property visibility A function that determines whether the setting is visible.
*/
abstract class AbstractSetting<T : Any>(
internal val defaultValue: T,
override var name: String,
internal var defaultValue: T,
val type: Type,
val description: String,
val visibility: () -> Boolean,
) : Jsonable, Nameable, Layout {
override var description: String,
var visibility: () -> Boolean,
) : Jsonable, Nameable, Describable, Layout {
private val listeners = mutableListOf<ValueListener<T>>()
val groups: MutableList<List<NamedEnum>> = mutableListOf()
var groups: MutableList<List<NamedEnum>> = mutableListOf()

var value by Delegates.observable(defaultValue) { _, from, to ->
listeners.forEach {
Expand Down Expand Up @@ -185,7 +187,7 @@ abstract class AbstractSetting<T : Any>(
val previous = this@AbstractSetting.value
try {
loadFromJson(parsed)
} catch (e: Exception) {
} catch (_: Exception) {
return@executeWithResult failure("Failed to load $valueString as a ${type::class.simpleName} for $name in ${config.name}.")
}
ConfigCommand.info(setMessage(previous, this@AbstractSetting.value))
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/lambda/config/Configurable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import java.awt.Color
abstract class Configurable(
private val configuration: Configuration,
) : Jsonable, Nameable {
val settings = mutableSetOf<AbstractSetting<*>>()
val settings = mutableListOf<AbstractSetting<*>>()

init {
registerConfigurable()
Expand Down
98 changes: 49 additions & 49 deletions src/main/kotlin/com/lambda/config/groups/BreakSettings.kt

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions src/main/kotlin/com/lambda/config/groups/BuildConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package com.lambda.config.groups

import com.lambda.interaction.request.rotating.visibilty.PointSelection
import com.lambda.util.Describable
import com.lambda.util.NamedEnum

Expand All @@ -29,14 +30,15 @@ interface BuildConfig {
val maxPendingInteractions: Int
val interactionTimeout: Int

// Breaking
val breakConfig: BreakSettings
val useDefaultReach: Boolean
val attackReach: Double
val interactReach: Double
val scanReach: Double

// Placing
val placeConfig: PlaceSettings

// Interacting
val interactConfig: InteractSettings
val strictRayCast: Boolean
val checkSideVisibility: Boolean
val resolution: Int
val pointSelection: PointSelection

enum class SwingType(
override val displayName: String,
Expand Down
55 changes: 28 additions & 27 deletions src/main/kotlin/com/lambda/config/groups/BuildSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,42 @@
package com.lambda.config.groups

import com.lambda.config.Configurable
import com.lambda.interaction.request.breaking.BreakConfig.BreakConfirmationMode
import com.lambda.interaction.request.placing.PlaceConfig
import com.lambda.interaction.request.rotating.visibilty.PointSelection
import com.lambda.util.NamedEnum
import kotlin.math.max

class BuildSettings(
c: Configurable,
vararg groupPath: NamedEnum,
vararg baseGroup: NamedEnum,
vis: () -> Boolean = { true },
) : BuildConfig {
) : BuildConfig, SettingGroup(c) {
enum class Group(override val displayName: String) : NamedEnum {
General("General"),
Break("Break"),
Place("Place"),
Interact("Interact")
Reach("Reach"),
Scan("Scan")
}

// General
override val pathing by c.setting("Pathing", true, "Path to blocks", vis).group(*groupPath, Group.General)
override val stayInRange by c.setting("Stay In Range", true, "Stay in range of blocks", vis).group(*groupPath, Group.General)
override val collectDrops by c.setting("Collect All Drops", false, "Collect all drops when breaking blocks", vis).group(*groupPath, Group.General)
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)
override val maxPendingInteractions by c.setting("Max Pending Interactions", 15, 1..30, 1, "The maximum count of pending interactions to allow before pausing future interactions", visibility = vis).group(*groupPath, Group.General)

// Breaking
override val breakConfig = BreakSettings(c, groupPath.toList() + Group.Break, vis)

// Placing
override val placeConfig = PlaceSettings(c, groupPath.toList() + Group.Place, vis)

//Interacting
override val interactConfig = InteractSettings(c, groupPath.toList() + Group.Interact, vis)

override val interactionTimeout by c.setting("Interaction Timeout", 10, 1..30, 1, "Timeout for block breaks in ticks", unit = " ticks") {
vis() && (placeConfig.placeConfirmationMode != PlaceConfig.PlaceConfirmationMode.None
|| breakConfig.breakConfirmation != BreakConfirmationMode.None
|| interactConfig.interactConfirmationMode != InteractionConfig.InteractConfirmationMode.None)
}.group(*groupPath, Group.Break, BreakSettings.Group.General).group(*groupPath, Group.Place).group(*groupPath, Group.Interact)
override val pathing by c.setting("Pathing", true, "Path to blocks", vis).group(*baseGroup, Group.General)
override val stayInRange by c.setting("Stay In Range", true, "Stay in range of blocks", vis).group(*baseGroup, Group.General)
override val collectDrops by c.setting("Collect All Drops", false, "Collect all drops when breaking blocks", vis).group(*baseGroup, Group.General)
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)
override val maxPendingInteractions by c.setting("Max Pending Interactions", 15, 1..30, 1, "The maximum count of pending interactions to allow before pausing future interactions", visibility = vis).group(*baseGroup, Group.General)
override val interactionTimeout by c.setting("Interaction Timeout", 10, 1..30, 1, "Timeout for block breaks in ticks", unit = " ticks", visibility = vis).group(*baseGroup, Group.General)

override val useDefaultReach by c.setting("Default Reach", true, "Whether to use vanilla interaction ranges", vis).group(*baseGroup, Group.Reach)
override val attackReach by c.setting("Attack Reach", DEFAULT_ATTACK_REACH, 1.0..10.0, 0.01, "Maximum entity interaction distance") { vis() && !useDefaultReach }.group(*baseGroup, Group.Reach)
override val interactReach by c.setting("Interact Reach", DEFAULT_INTERACT_REACH, 1.0..10.0, 0.01, "Maximum block interaction distance") { vis() && !useDefaultReach }.group(*baseGroup, Group.Reach)

override val scanReach: Double get() = max(attackReach, interactReach)

override val strictRayCast by c.setting("Strict Raycast", false, "Whether to include the environment to the ray cast context", vis).group(*baseGroup, Group.Scan)
override val checkSideVisibility by c.setting("Visibility Check", true, "Whether to check if an AABB side is visible", vis).group(*baseGroup, Group.Scan)
override val resolution by c.setting("Resolution", 5, 1..20, 1, "The amount of grid divisions per surface of the hit box", "", vis).group(*baseGroup, Group.Scan)
override val pointSelection by c.setting("Point Selection", PointSelection.Optimum, "The strategy to select the best hit point", vis).group(*baseGroup, Group.Scan)

companion object {
const val DEFAULT_ATTACK_REACH = 3.0
const val DEFAULT_INTERACT_REACH = 4.5
}
}
3 changes: 1 addition & 2 deletions src/main/kotlin/com/lambda/config/groups/EatSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ package com.lambda.config.groups

import com.lambda.config.Configurable
import com.lambda.util.NamedEnum
import net.minecraft.item.Item
import net.minecraft.item.Items

class EatSettings(
c: Configurable,
baseGroup: NamedEnum,
vis: () -> Boolean = { true }
) : EatConfig {
) : EatConfig, SettingGroup(c) {
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)
val resistanceFoodDefaults = listOf(Items.ENCHANTED_GOLDEN_APPLE)
val regenerationFoodDefaults = listOf(Items.ENCHANTED_GOLDEN_APPLE, Items.GOLDEN_APPLE)
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class HotbarSettings(
c: Configurable,
baseGroup: NamedEnum,
vis: () -> Boolean = { true }
) : HotbarConfig {
override val keepTicks by c.setting("Keep Ticks", 3, 0..20, 1, "The number of ticks to keep the current hotbar selection active", " ticks", visibility = vis).group(baseGroup)
) : HotbarConfig, SettingGroup(c) {
override val keepTicks by c.setting("Keep Ticks", 1, 0..20, 1, "The number of ticks to keep the current hotbar selection active", " ticks", visibility = vis).group(baseGroup)
override val swapDelay by c.setting("Swap Delay", 0, 0..3, 1, "The number of ticks delay before allowing another hotbar selection swap", " ticks", visibility = vis).group(baseGroup)
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 && vis() }.group(baseGroup)
override val swapPause by c.setting("Swap Pause", 0, 0..20, 1, "The delay in ticks to pause actions after switching to the slot", " ticks", visibility = vis).group(baseGroup)
Expand Down
14 changes: 7 additions & 7 deletions src/main/kotlin/com/lambda/config/groups/InteractSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import com.lambda.util.NamedEnum

class InteractSettings(
c: Configurable,
groupPath: List<NamedEnum> = emptyList(),
baseGroup: NamedEnum,
vis: () -> Boolean = { true }
) : InteractConfig {
override val rotate by c.setting("Rotate For Interact", true, "Rotates the player to look at the block when interacting", visibility = vis).group(groupPath)
override val swingHand by c.setting("Swing On Interact", true, "Swings the players hand after interacting", visibility = vis).group(groupPath)
override val interactStageMask by c.setting("Interact Stage Mask", setOf(TickEvent.Input.Post), description = "The sub-tick timing at which interact actions are performed", visibility = vis).group(groupPath)
override val interactSwingType by c.setting("Interact Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { vis() && swingHand }.group(groupPath)
override val interactConfirmationMode by c.setting("Interact Confirmation Mode", InteractionConfig.InteractConfirmationMode.InteractThenAwait, "The style of confirmation for interactions", visibility = vis).group(groupPath)
) : InteractConfig, SettingGroup(c) {
override val rotate by c.setting("Rotate For Interact", true, "Rotates the player to look at the block when interacting", visibility = vis).group(baseGroup)
override val swingHand by c.setting("Swing On Interact", true, "Swings the players hand after interacting", visibility = vis).group(baseGroup)
override val interactStageMask by c.setting("Interact Stage Mask", setOf(TickEvent.Input.Post), description = "The sub-tick timing at which interact actions are performed", visibility = vis).group(baseGroup)
override val interactSwingType by c.setting("Interact Swing Type", BuildConfig.SwingType.Vanilla, "The style of swing") { vis() && swingHand }.group(baseGroup)
override val interactConfirmationMode by c.setting("Interact Confirmation Mode", InteractConfig.InteractConfirmationMode.InteractThenAwait, "The style of confirmation for interactions", visibility = vis).group(baseGroup)
}
72 changes: 0 additions & 72 deletions src/main/kotlin/com/lambda/config/groups/InteractionConfig.kt

This file was deleted.

69 changes: 0 additions & 69 deletions src/main/kotlin/com/lambda/config/groups/InteractionSettings.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class InventorySettings(
c: Configurable,
baseGroup: NamedEnum,
vis: () -> Boolean = { true }
) : InventoryConfig {
) : InventoryConfig, SettingGroup(c) {
enum class Group(override val displayName: String) : NamedEnum {
Container("Container"),
Access("Access")
Expand Down
Loading