From b58345a6dc4c0ab0448b867717c097f3f55c4677 Mon Sep 17 00:00:00 2001 From: Ridan Vandenbergh Date: Mon, 5 Aug 2019 23:33:53 +0200 Subject: [PATCH] Add option to toggle key modifiers --- .../kami/command/commands/BindCommand.java | 30 +++++++++++++++++-- .../java/me/zeroeightsix/kami/util/Bind.java | 3 +- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/zeroeightsix/kami/command/commands/BindCommand.java b/src/main/java/me/zeroeightsix/kami/command/commands/BindCommand.java index bc13ae496..9b2ba7a2e 100644 --- a/src/main/java/me/zeroeightsix/kami/command/commands/BindCommand.java +++ b/src/main/java/me/zeroeightsix/kami/command/commands/BindCommand.java @@ -2,9 +2,13 @@ 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; /** @@ -12,10 +16,12 @@ */ public class BindCommand extends Command { + public static Setting 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() ); } @@ -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); diff --git a/src/main/java/me/zeroeightsix/kami/util/Bind.java b/src/main/java/me/zeroeightsix/kami/util/Bind.java index dcc13d845..9505f4a1f 100644 --- a/src/main/java/me/zeroeightsix/kami/util/Bind.java +++ b/src/main/java/me/zeroeightsix/kami/util/Bind.java @@ -1,5 +1,6 @@ package me.zeroeightsix.kami.util; +import me.zeroeightsix.kami.command.commands.BindCommand; import org.lwjgl.input.Keyboard; /** @@ -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() {