diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/InventoryManager.kt b/src/main/kotlin/com/lambda/client/module/modules/player/InventoryManager.kt index a6b292a39..c4cf875d4 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/InventoryManager.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/InventoryManager.kt @@ -47,7 +47,7 @@ object InventoryManager : Module( private val pauseMovement by setting("Pause Movement", true) private val delay by setting("Delay Ticks", 1, 0..20, 1, unit = " ticks") private val helpMend by setting("Help Mend", false, description = "Helps mending items by replacing the offhand item with low HP items of the same type") - val ejectList = setting(CollectionSetting("Eject List", defaultEjectList, String::class.java)) + val ejectList = setting(CollectionSetting("Eject List", defaultEjectList)) enum class State { IDLE, SAVING_ITEM, HELPING_MEND, REFILLING_BUILDING, REFILLING, EJECTING diff --git a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt index b8947199e..4d4dbab86 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/player/Scaffold.kt @@ -67,8 +67,8 @@ object Scaffold : Module( private val thickness by setting("Outline Thickness", 2f, .25f..4f, .25f, { outline && page == Page.RENDER }, description = "Changes thickness of the outline") private val pendingBlockColor by setting("Pending Color", ColorHolder(0, 0, 255), visibility = { page == Page.RENDER }) - val blockSelectionWhitelist = setting(CollectionSetting("BlockWhitelist", linkedSetOf("minecraft:obsidian"), String::class.java, { false })) - val blockSelectionBlacklist = setting(CollectionSetting("BlockBlacklist", blockBlacklist.map { it.registryName.toString() }.toMutableSet(), String::class.java, { false })) + val blockSelectionWhitelist = setting(CollectionSetting("BlockWhitelist", linkedSetOf("minecraft:obsidian"), { false })) + val blockSelectionBlacklist = setting(CollectionSetting("BlockBlacklist", blockBlacklist.map { it.registryName.toString() }.toMutableSet(), { false })) private enum class Page { GENERAL, RENDER diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/Search.kt b/src/main/kotlin/com/lambda/client/module/modules/render/Search.kt index f95f04ea4..31e1a09f9 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/Search.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/Search.kt @@ -70,10 +70,10 @@ object Search : Module( private val hideF1 by setting("Hide on F1", true) var overrideWarning by setting("Override Warning", false, { false }) - val blockSearchList = setting(CollectionSetting("Search List", defaultSearchList, String::class.java, { false })) - val entitySearchList = setting(CollectionSetting("Entity Search List", linkedSetOf(EntityList.getKey((EntityItemFrame::class.java))!!.path), String::class.java, { false })) - val blockSearchDimensionFilter = setting(CollectionSetting("Block Dimension Filter", linkedSetOf(), DimensionFilter::class.java, { false })) - val entitySearchDimensionFilter = setting(CollectionSetting("Entity Dimension Filter", linkedSetOf(), DimensionFilter::class.java, { false })) + val blockSearchList = setting(CollectionSetting("Search List", defaultSearchList, { false })) + val entitySearchList = setting(CollectionSetting("Entity Search List", linkedSetOf(EntityList.getKey((EntityItemFrame::class.java))!!.path), { false })) + val blockSearchDimensionFilter = setting(CollectionSetting("Block Dimension Filter", linkedSetOf(), entryType = DimensionFilter::class.java, visibility = { false })) + val entitySearchDimensionFilter = setting(CollectionSetting("Entity Dimension Filter", linkedSetOf(), entryType = DimensionFilter::class.java, visibility = { false })) private val blockRenderer = ESPRenderer() private val entityRenderer = ESPRenderer() diff --git a/src/main/kotlin/com/lambda/client/module/modules/render/Xray.kt b/src/main/kotlin/com/lambda/client/module/modules/render/Xray.kt index 5fa24ecec..f8cede12d 100644 --- a/src/main/kotlin/com/lambda/client/module/modules/render/Xray.kt +++ b/src/main/kotlin/com/lambda/client/module/modules/render/Xray.kt @@ -14,7 +14,7 @@ object Xray : Module( ) { private val defaultVisibleList = linkedSetOf("minecraft:diamond_ore", "minecraft:iron_ore", "minecraft:gold_ore", "minecraft:portal", "minecraft:cobblestone") - val visibleList = setting(CollectionSetting("Visible List", defaultVisibleList, String::class.java, { false })) + val visibleList = setting(CollectionSetting("Visible List", defaultVisibleList, { false })) @JvmStatic fun shouldReplace(state: IBlockState): Boolean { diff --git a/src/main/kotlin/com/lambda/client/setting/settings/impl/collection/CollectionSetting.kt b/src/main/kotlin/com/lambda/client/setting/settings/impl/collection/CollectionSetting.kt index 372635c21..ce1afaf80 100644 --- a/src/main/kotlin/com/lambda/client/setting/settings/impl/collection/CollectionSetting.kt +++ b/src/main/kotlin/com/lambda/client/setting/settings/impl/collection/CollectionSetting.kt @@ -7,15 +7,25 @@ import com.lambda.client.setting.settings.ImmutableSetting class CollectionSetting>( name: String, override val value: T, - entryType: Class, visibility: () -> Boolean = { true }, description: String = "", unit: String = "" ) : ImmutableSetting(name, value, visibility, { _, input -> input }, description, unit), MutableCollection by value { + constructor( + name: String, + value: T, + visibility: () -> Boolean = { true }, + description: String = "", + unit: String = "", + entryType: Class, // type must be set if the default collection is empty + ) : this(name, value, visibility, description, unit) { + this.entryType = entryType + } + + private var entryType: Class? = null override val defaultValue: T = valueClass.newInstance() private val lockObject = Any() - private val type = TypeToken.getArray(entryType).type val editListeners = ArrayList<() -> Unit>() init { @@ -41,7 +51,7 @@ class CollectionSetting>( override fun read(jsonElement: JsonElement?) { jsonElement?.asJsonArray?.let { - val cacheArray = gson.fromJson>(it, type) + val cacheArray = gson.fromJson>(it, TypeToken.getArray(entryType ?: value.first().javaClass).type) synchronized(lockObject) { value.clear() value.addAll(cacheArray)