Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Commit b58345a

Browse files
committed
Add option to toggle key modifiers
1 parent 7aaaf87 commit b58345a

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

src/main/java/me/zeroeightsix/kami/command/commands/BindCommand.java

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,26 @@
22

33
import me.zeroeightsix.kami.command.Command;
44
import me.zeroeightsix.kami.command.syntax.ChunkBuilder;
5+
import me.zeroeightsix.kami.command.syntax.parsers.DependantParser;
56
import me.zeroeightsix.kami.command.syntax.parsers.ModuleParser;
67
import me.zeroeightsix.kami.module.Module;
78
import me.zeroeightsix.kami.module.ModuleManager;
9+
import me.zeroeightsix.kami.setting.Setting;
10+
import me.zeroeightsix.kami.setting.Settings;
11+
import me.zeroeightsix.kami.setting.builder.SettingBuilder;
812
import me.zeroeightsix.kami.util.Wrapper;
913

1014
/**
1115
* Created by 086 on 12/11/2017.
1216
*/
1317
public class BindCommand extends Command {
1418

19+
public static Setting<Boolean> modifiersEnabled = SettingBuilder.register(Settings.b("modifiersEnabled"), "binds");
20+
1521
public BindCommand() {
1622
super("bind", new ChunkBuilder()
17-
.append("module", true, new ModuleParser())
18-
.append("key", true)
23+
.append("[module]|modifiers", true, new ModuleParser())
24+
.append("[key]|[on|off]", true)
1925
.build()
2026
);
2127
}
@@ -27,8 +33,26 @@ public void call(String[] args) {
2733
return;
2834
}
2935

30-
String rkey = args[1];
3136
String module = args[0];
37+
String rkey = args[1];
38+
39+
if (module.equalsIgnoreCase("modifiers")) {
40+
if (rkey == null) {
41+
sendChatMessage("Expected: on or off");
42+
return;
43+
}
44+
45+
if (rkey.equalsIgnoreCase("on")) {
46+
modifiersEnabled.setValue(true);
47+
sendChatMessage("Turned modifiers on.");
48+
} else if (rkey.equalsIgnoreCase("off")) {
49+
modifiersEnabled.setValue(false);
50+
sendChatMessage("Turned modifiers off.");
51+
} else {
52+
sendChatMessage("Expected: on or off");
53+
}
54+
return;
55+
}
3256

3357
Module m = ModuleManager.getModuleByName(module);
3458

src/main/java/me/zeroeightsix/kami/util/Bind.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package me.zeroeightsix.kami.util;
22

3+
import me.zeroeightsix.kami.command.commands.BindCommand;
34
import org.lwjgl.input.Keyboard;
45

56
/**
@@ -61,7 +62,7 @@ public String toString() {
6162
}
6263

6364
public boolean isDown() {
64-
return !isEmpty() && (isShift() == isShiftDown()) && (isCtrl() == isCtrlDown()) && (isAlt() == isAltDown()) && Keyboard.isKeyDown(getKey());
65+
return !isEmpty() && (!BindCommand.modifiersEnabled.getValue() || (isShift() == isShiftDown()) && (isCtrl() == isCtrlDown()) && (isAlt() == isAltDown())) && Keyboard.isKeyDown(getKey());
6566
}
6667

6768
private boolean isShiftDown() {

0 commit comments

Comments
 (0)