1717
1818package com.lambda.module.modules.player
1919
20+ import com.lambda.config.settings.complex.Bind
2021import com.lambda.event.events.MouseEvent
2122import com.lambda.event.listener.SafeListener.Companion.listen
2223import com.lambda.friend.FriendManager
@@ -26,49 +27,32 @@ import com.lambda.friend.FriendManager.unfriend
2627import com.lambda.module.Module
2728import com.lambda.module.tag.ModuleTag
2829import com.lambda.util.Communication.info
29- import com.lambda.util.Mouse
3030import com.lambda.util.world.raycast.RayCastUtils.entityResult
3131import 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
3934object 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