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

Commit

Permalink
Add option to toggle key modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroeightysix committed Aug 5, 2019
1 parent 7aaaf87 commit b58345a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@

import me.zeroeightsix.kami.command.Command;
import me.zeroeightsix.kami.command.syntax.ChunkBuilder;
import me.zeroeightsix.kami.command.syntax.parsers.DependantParser;
import me.zeroeightsix.kami.command.syntax.parsers.ModuleParser;
import me.zeroeightsix.kami.module.Module;
import me.zeroeightsix.kami.module.ModuleManager;
import me.zeroeightsix.kami.setting.Setting;
import me.zeroeightsix.kami.setting.Settings;
import me.zeroeightsix.kami.setting.builder.SettingBuilder;
import me.zeroeightsix.kami.util.Wrapper;

/**
* Created by 086 on 12/11/2017.
*/
public class BindCommand extends Command {

public static Setting<Boolean> modifiersEnabled = SettingBuilder.register(Settings.b("modifiersEnabled"), "binds");

public BindCommand() {
super("bind", new ChunkBuilder()
.append("module", true, new ModuleParser())
.append("key", true)
.append("[module]|modifiers", true, new ModuleParser())
.append("[key]|[on|off]", true)
.build()
);
}
Expand All @@ -27,8 +33,26 @@ public void call(String[] args) {
return;
}

String rkey = args[1];
String module = args[0];
String rkey = args[1];

if (module.equalsIgnoreCase("modifiers")) {
if (rkey == null) {
sendChatMessage("Expected: on or off");
return;
}

if (rkey.equalsIgnoreCase("on")) {
modifiersEnabled.setValue(true);
sendChatMessage("Turned modifiers on.");
} else if (rkey.equalsIgnoreCase("off")) {
modifiersEnabled.setValue(false);
sendChatMessage("Turned modifiers off.");
} else {
sendChatMessage("Expected: on or off");
}
return;
}

Module m = ModuleManager.getModuleByName(module);

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/me/zeroeightsix/kami/util/Bind.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.zeroeightsix.kami.util;

import me.zeroeightsix.kami.command.commands.BindCommand;
import org.lwjgl.input.Keyboard;

/**
Expand Down Expand Up @@ -61,7 +62,7 @@ public String toString() {
}

public boolean isDown() {
return !isEmpty() && (isShift() == isShiftDown()) && (isCtrl() == isCtrlDown()) && (isAlt() == isAltDown()) && Keyboard.isKeyDown(getKey());
return !isEmpty() && (!BindCommand.modifiersEnabled.getValue() || (isShift() == isShiftDown()) && (isCtrl() == isCtrlDown()) && (isAlt() == isAltDown())) && Keyboard.isKeyDown(getKey());
}

private boolean isShiftDown() {
Expand Down

0 comments on commit b58345a

Please sign in to comment.