Skip to content

Commit 8ca1550

Browse files
committed
fixed the recursive error
1 parent ae33379 commit 8ca1550

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/main/kotlin/com/lambda/module/modules/player/ClickFriend.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,11 @@ object ClickFriend : Module(
3838
description = "Add or remove friends with a single click",
3939
tag = ModuleTag.PLAYER,
4040
) {
41-
private val friendBind = setting("Friend Bind", Bind(0, 0, GLFW.GLFW_MOUSE_BUTTON_MIDDLE), "Bind to press to befriend a player")
42-
private val unfriendBind = setting("Unfriend Bind", Bind(0, GLFW_MOD_SHIFT, GLFW.GLFW_MOUSE_BUTTON_MIDDLE), "Bind to press to unfriend a player")
41+
private val friendBind: Bind by setting("Friend Bind", Bind(0, 0, GLFW.GLFW_MOUSE_BUTTON_MIDDLE), "Bind to press to befriend a player")
42+
.onPress { if (!unfriendBind.isSatisfied()) if (checkSetFriend(true)) it.cancel() }
4343

44-
init {
45-
// onPress listeners applied here to avoid recursion warning
46-
friendBind.onPress { if (!unfriendBind.value.isSatisfied()) if (checkSetFriend(true)) it.cancel() }
47-
unfriendBind.onPress { if (!friendBind.value.isSatisfied()) if (checkSetFriend(false)) it.cancel() }
48-
}
44+
private val unfriendBind: Bind by setting("Unfriend Bind", Bind(0, GLFW_MOD_SHIFT, GLFW.GLFW_MOUSE_BUTTON_MIDDLE), "Bind to press to unfriend a player")
45+
.onPress { if (!friendBind.isSatisfied()) if (checkSetFriend(false)) it.cancel() }
4946

5047
private fun SafeContext.checkSetFriend(friend: Boolean): Boolean {
5148
val target = mc.crosshairTarget?.entityResult?.entity as? OtherClientPlayerEntity

0 commit comments

Comments
 (0)