Skip to content

Commit 6790b29

Browse files
committed
Added proper key binds for click friend
1 parent 82bbb73 commit 6790b29

File tree

1 file changed

+9
-25
lines changed

1 file changed

+9
-25
lines changed

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

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package com.lambda.module.modules.player
1919

20+
import com.lambda.config.settings.complex.Bind
2021
import com.lambda.event.events.MouseEvent
2122
import com.lambda.event.listener.SafeListener.Companion.listen
2223
import com.lambda.friend.FriendManager
@@ -26,49 +27,32 @@ import com.lambda.friend.FriendManager.unfriend
2627
import com.lambda.module.Module
2728
import com.lambda.module.tag.ModuleTag
2829
import com.lambda.util.Communication.info
29-
import com.lambda.util.Mouse
3030
import com.lambda.util.world.raycast.RayCastUtils.entityResult
3131
import net.minecraft.client.network.OtherClientPlayerEntity
32-
import org.lwjgl.glfw.GLFW.GLFW_MOD_ALT
33-
import org.lwjgl.glfw.GLFW.GLFW_MOD_CAPS_LOCK
34-
import org.lwjgl.glfw.GLFW.GLFW_MOD_CONTROL
35-
import org.lwjgl.glfw.GLFW.GLFW_MOD_NUM_LOCK
36-
import org.lwjgl.glfw.GLFW.GLFW_MOD_SHIFT
37-
import org.lwjgl.glfw.GLFW.GLFW_MOD_SUPER
32+
import org.lwjgl.glfw.GLFW
3833

3934
object ClickFriend : Module(
4035
name = "ClickFriend",
4136
description = "Add or remove friends with a single click",
4237
tag = ModuleTag.PLAYER,
4338
) {
44-
private val friendButton by setting("Friend Button", Mouse.Button.Middle, description = "Button to press to befriend a player")
45-
private val friendAction by setting("Action", Mouse.Action.Release, description = "What mouse action should add or remove the player")
46-
private val comboUnfriend by setting("Combo Unfriend", false, description = "Press a key and right click a player to unfriend")
47-
private val modUnfriend by setting("Combo Key", MouseMod.Shift, description = "The key to press to activate the unfriend combo") { comboUnfriend }
39+
private val friendBind by setting("Friend Bind", Bind(0, 0, GLFW.GLFW_MOUSE_BUTTON_MIDDLE), "Bind to press to befriend a player")
40+
private val unfriendBind by setting("Unfriend Bind", friendBind, "Bind to press to unfriend a player")
4841

4942
init {
5043
listen<MouseEvent.Click> {
5144
if (mc.currentScreen != null) return@listen
52-
if (it.button != friendButton.ordinal || it.action != friendAction.ordinal) return@listen
5345

5446
val target = mc.crosshairTarget?.entityResult?.entity as? OtherClientPlayerEntity
5547
?: return@listen
5648

57-
if (!it.hasModifier(modUnfriend.modifiers) && comboUnfriend && target.isFriend) return@listen
58-
5949
when {
60-
target.isFriend && target.unfriend() -> info(FriendManager.unfriendedText(target.name))
61-
!target.isFriend && target.befriend() -> info(FriendManager.befriendedText(target.name))
50+
it.satisfies(friendBind) && !target.isFriend && target.befriend() ->
51+
info(FriendManager.befriendedText(target.name))
52+
53+
it.satisfies(unfriendBind) && target.isFriend && target.unfriend() ->
54+
info(FriendManager.unfriendedText(target.name))
6255
}
6356
}
6457
}
65-
66-
private enum class MouseMod(val modifiers: Int) {
67-
Shift(GLFW_MOD_SHIFT),
68-
Control(GLFW_MOD_CONTROL),
69-
Alt(GLFW_MOD_ALT),
70-
Super(GLFW_MOD_SUPER),
71-
Caps(GLFW_MOD_CAPS_LOCK),
72-
NumLock(GLFW_MOD_NUM_LOCK);
73-
}
7458
}

0 commit comments

Comments
 (0)