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
19 changes: 4 additions & 15 deletions src/main/kotlin/com/lambda/config/Configurable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -151,33 +151,22 @@ abstract class Configurable(
) = Setting(name, description, ItemCollectionSetting(immutableCollection, defaultValue.toMutableList()), this, visibility).register()

@JvmName("collectionSetting3")
inline fun <reified T : Comparable<T>> setting(
inline fun <reified T : Any> setting(
name: String,
defaultValue: Collection<T>,
immutableList: Collection<T> = defaultValue,
description: String = "",
displayClassName: Boolean = false,
noinline visibility: () -> Boolean = { true },
) = Setting(
name,
description,
CollectionSetting(
defaultValue.toMutableList(),
immutableList,
TypeToken.getParameterized(Collection::class.java, T::class.java).type
),
if (displayClassName) ClassCollectionSetting(immutableList, defaultValue.toMutableList())
else CollectionSetting(defaultValue.toMutableList(), immutableList, TypeToken.getParameterized(Collection::class.java, T::class.java).type),
this,
visibility
).register()

@JvmName("collectionSetting4")
inline fun <reified T : Any> setting(
name: String,
defaultValue: Collection<T>,
immutableList: Collection<T> = defaultValue,
description: String = "",
noinline visibility: () -> Boolean = { true },
) = Setting(name, description, ClassCollectionSetting(immutableList, defaultValue.toMutableList()), this, visibility).register()

// ToDo: Actually implement maps
inline fun <reified K : Any, reified V : Any> setting(
name: String,
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/lambda/config/groups/BreakSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ open class BreakSettings(
override val breakDelay by c.setting("Break Delay", 0, 0..5, 1, "The delay between breaking blocks", " tick(s)").group(baseGroup, Group.General).index()

// Timing
override val tickStageMask by c.setting("Break Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), description = "The sub-tick timing at which break actions can be performed").group(baseGroup, Group.General).index()
override val tickStageMask by c.setting("Break Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), "The sub-tick timing at which break actions can be performed", displayClassName = true).group(baseGroup, Group.General).index()

// Swap
override val swapMode by c.setting("Break Swap Mode", BreakConfig.SwapMode.End, "Decides when to swap to the best suited tool when breaking a block").group(baseGroup, Group.General).index()
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/lambda/config/groups/HotbarSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ class HotbarSettings(
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()
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()
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").group(baseGroup).index()
override val tickStageMask by c.setting("Hotbar Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), description = "The sub-tick timing at which hotbar actions are performed").group(baseGroup).index()
override val tickStageMask by c.setting("Hotbar Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), "The sub-tick timing at which hotbar actions are performed", displayClassName = true).group(baseGroup).index()
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class InteractSettings(
override val airPlace by c.setting("Air Place", AirPlaceMode.None, "Allows for placing blocks without adjacent faces").group(baseGroup).index()
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()
override val sorter by c.setting("Interaction Sorter", ActionConfig.SortMode.Tool, "The order in which placements are performed").group(baseGroup).index()
override val tickStageMask by c.setting("Interaction Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), description = "The sub-tick timing at which place actions are performed").group(baseGroup).index()
override val tickStageMask by c.setting("Interaction Stage Mask", setOf(TickEvent.Input.Post), ALL_STAGES.toSet(), "The sub-tick timing at which place actions are performed", displayClassName = true).group(baseGroup).index()
override val interactConfirmationMode by c.setting("Interact Confirmation", InteractConfirmationMode.PlaceThenAwait, "Wait for block placement confirmation").group(baseGroup).index()
override val interactDelay by c.setting("Interact Delay", 0, 0..3, 1, "Tick delay between interacting with another block").group(baseGroup).index()
override val interactionsPerTick by c.setting("Interactions Per Tick", 1, 1..30, 1, "Maximum instant block places per tick").group(baseGroup).index()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package com.lambda.config.settings.collections

import com.google.gson.JsonArray
import com.google.gson.JsonElement
import com.google.gson.reflect.TypeToken
import com.lambda.Lambda.gson
Expand Down Expand Up @@ -106,7 +107,7 @@ open class CollectionSetting<R : Any>(

context(setting: Setting<*, MutableCollection<R>>)
override fun toJson(): JsonElement =
gson.toJsonTree(value.map { it.toString() })
gson.toJsonTree(value)

context(setting: Setting<*, MutableCollection<R>>)
override fun loadFromJson(serialized: JsonElement) {
Expand Down