Skip to content

Commit 5e2eb4d

Browse files
committed
don't map collectionsetting values, convert to json tree
1 parent 430b463 commit 5e2eb4d

File tree

5 files changed

+9
-19
lines changed

5 files changed

+9
-19
lines changed

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

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -151,33 +151,22 @@ abstract class Configurable(
151151
) = Setting(name, description, ItemCollectionSetting(immutableCollection, defaultValue.toMutableList()), this, visibility).register()
152152

153153
@JvmName("collectionSetting3")
154-
inline fun <reified T : Comparable<T>> setting(
154+
inline fun <reified T : Any> setting(
155155
name: String,
156156
defaultValue: Collection<T>,
157157
immutableList: Collection<T> = defaultValue,
158158
description: String = "",
159+
displayClassName: Boolean = false,
159160
noinline visibility: () -> Boolean = { true },
160161
) = Setting(
161162
name,
162163
description,
163-
CollectionSetting(
164-
defaultValue.toMutableList(),
165-
immutableList,
166-
TypeToken.getParameterized(Collection::class.java, T::class.java).type
167-
),
164+
if (displayClassName) ClassCollectionSetting(immutableList, defaultValue.toMutableList())
165+
else CollectionSetting(defaultValue.toMutableList(), immutableList, TypeToken.getParameterized(Collection::class.java, T::class.java).type),
168166
this,
169167
visibility
170168
).register()
171169

172-
@JvmName("collectionSetting4")
173-
inline fun <reified T : Any> setting(
174-
name: String,
175-
defaultValue: Collection<T>,
176-
immutableList: Collection<T> = defaultValue,
177-
description: String = "",
178-
noinline visibility: () -> Boolean = { true },
179-
) = Setting(name, description, ClassCollectionSetting(immutableList, defaultValue.toMutableList()), this, visibility).register()
180-
181170
// ToDo: Actually implement maps
182171
inline fun <reified K : Any, reified V : Any> setting(
183172
name: String,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ open class BreakSettings(
5757
override val breakDelay by c.setting("Break Delay", 0, 0..5, 1, "The delay between breaking blocks", " tick(s)").group(baseGroup, Group.General).index()
5858

5959
// Timing
60-
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()
60+
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()
6161

6262
// Swap
6363
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()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ class HotbarSettings(
3333
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()
3434
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()
3535
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()
36-
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()
36+
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()
3737
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class InteractSettings(
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()
3636
override val sorter by c.setting("Interaction Sorter", ActionConfig.SortMode.Tool, "The order in which placements are performed").group(baseGroup).index()
37-
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()
37+
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()
3838
override val interactConfirmationMode by c.setting("Interact Confirmation", InteractConfirmationMode.PlaceThenAwait, "Wait for block placement confirmation").group(baseGroup).index()
3939
override val interactDelay by c.setting("Interact Delay", 0, 0..3, 1, "Tick delay between interacting with another block").group(baseGroup).index()
4040
override val interactionsPerTick by c.setting("Interactions Per Tick", 1, 1..30, 1, "Maximum instant block places per tick").group(baseGroup).index()

src/main/kotlin/com/lambda/config/settings/collections/CollectionSetting.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.lambda.config.settings.collections
1919

20+
import com.google.gson.JsonArray
2021
import com.google.gson.JsonElement
2122
import com.google.gson.reflect.TypeToken
2223
import com.lambda.Lambda.gson
@@ -106,7 +107,7 @@ open class CollectionSetting<R : Any>(
106107

107108
context(setting: Setting<*, MutableCollection<R>>)
108109
override fun toJson(): JsonElement =
109-
gson.toJsonTree(value.map { it.toString() })
110+
gson.toJsonTree(value)
110111

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

0 commit comments

Comments
 (0)