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
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class CapeFeatureRendererMixin {
@ModifyExpressionValue(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/state/PlayerEntityRenderState;FF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/SkinTextures;capeTexture()Lnet/minecraft/util/Identifier;"))
Identifier renderCape(Identifier original, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, PlayerEntityRenderState player, float f, float g) {
var entry = Lambda.getMc().getNetworkHandler().getPlayerListEntry(player.name);
var entry = Lambda.getMc().getNetworkHandler().getPlayerListEntry(player.name); // this will cause issues if we try to render while not in game
if (entry == null) return original;

var profile = entry.getProfile();
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/com/lambda/command/commands/ModuleCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.lambda.util.Communication.info
import com.lambda.util.Communication.joinToText
import com.lambda.util.Communication.warn
import com.lambda.util.StringUtils
import com.lambda.util.StringUtils.findSimilarStrings
import com.lambda.util.extension.CommandBuilder
import com.lambda.util.text.ClickEvents.suggestCommand
import com.lambda.util.text.buildText
Expand Down Expand Up @@ -93,8 +94,7 @@ object ModuleCommand : LambdaCommand(
}
literal("not found!")
}
val similarModules = StringUtils.findSimilarStrings(
name,
val similarModules = name.findSimilarStrings(
ModuleRegistry.moduleNames,
3
)
Expand Down
232 changes: 7 additions & 225 deletions src/main/kotlin/com/lambda/config/Configurable.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,43 +91,13 @@ abstract class Configurable(
}
}

/**
* Creates a [BooleanSetting] with the provided parameters and adds it to the [settings].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [Boolean] value of the setting.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
*
* ```kotlin
* private val foo by setting("Foo", true)
* ```
*
* @return The created [BooleanSetting].
*/
fun setting(
name: String,
defaultValue: Boolean,
description: String = "",
visibility: () -> Boolean = { true },
) = BooleanSetting(name, defaultValue, description, visibility).register()

/**
* Creates an [EnumSetting] with the provided parameters and adds it to the [settings].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [Enum] value of the setting.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
*
* ```kotlin
* enum class Foo { A, B, C }
* private val foo by setting("Foo", Foo.A)
* ```
*
*
* @return The created [EnumSetting].
*/
inline fun <reified T : Enum<T>> setting(
name: String,
defaultValue: T,
Expand All @@ -136,37 +106,13 @@ abstract class Configurable(
visibility: () -> Boolean = { true },
) = EnumSetting(name, defaultValue, description, visibility).register()

/**
* Creates a [CharSetting] with the provided parameters and adds it to the [settings].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [Char] value of the setting.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
*
* @return The created [CharSetting].
*/
fun setting(
name: String,
defaultValue: Char,
description: String = "",
visibility: () -> Boolean = { true },
) = CharSetting(name, defaultValue, description, visibility).register()

/**
* Creates a [StringSetting] with the provided parameters and adds it to the [settings].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [String] value of the setting.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
*
* ```kotlin
* private val foo by setting("Foo", "bar")
* ```
*
* @return The created [StringSetting].
*/
fun setting(
name: String,
defaultValue: String,
Expand All @@ -176,23 +122,6 @@ abstract class Configurable(
visibility: () -> Boolean = { true },
) = StringSetting(name, defaultValue, multiline, flags, description, visibility).register()

/**
* Constructs a [ListSetting] instance with the specified parameters and appends it to the [settings] collection.
*
* The type parameter [T] must either be a primitive type or a type with a registered type adapter in [Lambda.gson].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [List] value of type [T] for the setting.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
*
* ```kotlin
* // the parameter type is inferred from the defaultValue
* private val foo by setting("Foo", arrayListOf("bar", "baz"))
* ```
*
* @return The created [ListSetting].
*/
inline fun <reified T : Any> setting(
name: String,
immutableList: List<T>,
Expand All @@ -208,23 +137,6 @@ abstract class Configurable(
visibility,
).register()

/**
* Constructs a [MapSetting] instance with the specified parameters and appends it to the [settings] collection.
*
* The type parameter [K] and [V] must either be a primitive type or a type with a registered type adapter in [Lambda.gson].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [Map] value of type [K] and [V] for the setting.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
*
* ```kotlin
* // the parameter types are inferred from the defaultValue
* private val foo by setting("Foo", mapOf("bar" to 1, "baz" to 2))
* ```
*
* @return The created [MapSetting].
*/
inline fun <reified K : Any, reified V : Any> setting(
name: String,
defaultValue: Map<K, V>,
Expand All @@ -238,23 +150,6 @@ abstract class Configurable(
visibility
).register()

/**
* Constructs a [SetSetting] instance with the specified parameters and appends it to the [settings] collection.
*
* The type parameter [T] must either be a primitive type or a type with a registered type adapter in [Lambda.gson].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [Set] value of type [T] for the setting.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
*
* ```kotlin
* // the parameter type is inferred from the defaultValue
* private val foo by setting("Foo", setOf("bar", "baz"))
* ```
*
* @return The created [SetSetting].
*/
inline fun <reified T : Any> setting(
name: String,
immutableList: Set<T>,
Expand All @@ -270,21 +165,6 @@ abstract class Configurable(
visibility,
).register()

/**
* Creates a [DoubleSetting] with the provided parameters and adds it to the [settings].
*
* The value of the setting is coerced into the specified [range] and rounded to the nearest [step].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [Double] value of the setting.
* @param range The range within which the setting's value must fall.
* @param step The step to which the setting's value is rounded.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
* @param unit The unit of the setting. E.g. "°C", "m/s", "ms", "ticks", etc.
*
* @return The created [DoubleSetting].
*/
fun setting(
name: String,
defaultValue: Double,
Expand All @@ -295,21 +175,6 @@ abstract class Configurable(
visibility: () -> Boolean = { true },
) = DoubleSetting(name, defaultValue, range, step, description, unit, visibility).register()

/**
* Creates a [FloatSetting] with the provided parameters and adds it to the [settings].
*
* The value of the setting is coerced into the specified [range] and rounded to the nearest [step].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [Float] value of the setting.
* @param range The range within which the setting's value must fall.
* @param step The step to which the setting's value is rounded.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
* @param unit The unit of the setting. E.g. "°C", "m/s", "ms", "ticks", etc.
*
* @return The created [FloatSetting].
*/
fun setting(
name: String,
defaultValue: Float,
Expand All @@ -320,21 +185,6 @@ abstract class Configurable(
visibility: () -> Boolean = { true },
) = FloatSetting(name, defaultValue, range, step, description, unit, visibility).register()

/**
* Creates an [IntegerSetting] with the provided parameters and adds it to the [settings].
*
* The value of the setting is coerced into the specified [range] and rounded to the nearest [step].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [Int] value of the setting.
* @param range The range within which the setting's value must fall.
* @param step The step to which the setting's value is rounded.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
* @param unit The unit of the setting. E.g. "°C", "m/s", "ms", "ticks", etc.
*
* @return The created [IntegerSetting].
*/
fun setting(
name: String,
defaultValue: Int,
Expand All @@ -345,21 +195,6 @@ abstract class Configurable(
visibility: () -> Boolean = { true },
) = IntegerSetting(name, defaultValue, range, step, description, unit, visibility).register()

/**
* Creates a [LongSetting] with the provided parameters and adds it to the [settings].
*
* The value of the setting is coerced into the specified [range] and rounded to the nearest [step].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [Long] value of the setting.
* @param range The range within which the setting's value must fall.
* @param step The step to which the setting's value is rounded.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
* @param unit The unit of the setting. E.g. "°C", "m/s", "ms", "ticks", etc.
*
* @return The created [LongSetting].
*/
fun setting(
name: String,
defaultValue: Long,
Expand All @@ -370,101 +205,48 @@ abstract class Configurable(
visibility: () -> Boolean = { true },
) = LongSetting(name, defaultValue, range, step, description, unit, visibility).register()

/**
* Creates a [KeybindSetting] with the provided parameters and adds it to the [settings].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [KeyCode] value of the setting.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
*
* @return The created [KeybindSetting].
*/
fun setting(
name: String,
defaultValue: Bind,
description: String = "",
visibility: () -> Boolean = { true },
) = KeybindSetting(name, defaultValue, description, visibility).register()

/**
* Creates a [ColorSetting] with the provided parameters and adds it to the [settings].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [Color] value of the setting.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
*
* @return The created [ColorSetting].
*/
fun setting(
name: String,
defaultValue: KeyCode,
description: String = "",
visibility: () -> Boolean = { true },
) = KeybindSetting(name, defaultValue, description, visibility).register()

fun setting(
name: String,
defaultValue: Color,
description: String = "",
visibility: () -> Boolean = { true },
) = ColorSetting(name, defaultValue, description, visibility).register()

/**
* Creates a [Vec3dSetting] with the provided parameters and adds it to the [settings].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [Vec3d] value of the setting.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
*
* @return The created [Vec3dSetting].
*/
fun setting(
name: String,
defaultValue: Vec3d,
description: String = "",
visibility: () -> Boolean = { true },
) = Vec3dSetting(name, defaultValue, description, visibility).register()

/**
* Creates a [BlockPosSetting] with the provided parameters and adds it to the [settings].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [BlockPos.Mutable] value of the setting.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
*
* @return The created [BlockPosSetting].
*/
fun setting(
name: String,
defaultValue: BlockPos.Mutable,
description: String = "",
visibility: () -> Boolean = { true },
) = BlockPosSetting(name, defaultValue, description, visibility).register()

/**
* Creates a [BlockPosSetting] with the provided parameters and adds it to the [settings].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [BlockPos] value of the setting.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
*
* @return The created [BlockPosSetting].
*/
fun setting(
name: String,
defaultValue: BlockPos,
description: String = "",
visibility: () -> Boolean = { true },
) = BlockPosSetting(name, defaultValue, description, visibility).register()

/**
* Creates a [BlockSetting] with the provided parameters and adds it to the [settings].
*
* @param name The unique identifier for the setting.
* @param defaultValue The default [Block] value of the setting.
* @param description A brief explanation of the setting's purpose and behavior.
* @param visibility A lambda expression that determines the visibility status of the setting.
*
* @return The created [BlockSetting].
*/
fun setting(
name: String,
defaultValue: Block,
Expand Down
Loading
Loading