From cd7b08b4799b5ee08f1dca6ff92a28e74d9db102 Mon Sep 17 00:00:00 2001 From: inglettronald Date: Fri, 30 Jun 2023 03:55:49 -0500 Subject: Added Alias Code And Implemented Dynamic Key --- .../kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt') diff --git a/src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt b/src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt index fdca658..8e2112a 100644 --- a/src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt +++ b/src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt @@ -1,5 +1,6 @@ package com.dulkirfabric.features +import com.dulkirfabric.commands.DynamicKeyCommand import com.dulkirfabric.config.DulkirConfig import com.dulkirfabric.events.WorldKeyPressEvent import com.dulkirfabric.util.TextUtils @@ -20,14 +21,16 @@ object KeyShortCutImpl { lastCommandHandle = System.currentTimeMillis() prevCode = event.key - // This conditional allows for these shortcuts to work for commands or normal messages - // You have to do it this way because the messages are handled differently on the client - // side in modern versions of Minecraft. - if (it.command.startsWith("/")) - TextUtils.sendCommand(it.command.substring(1)) - else - TextUtils.sendMessage(it.command) + TextUtils.sendCommand(it.command.trimStart('/')) } } + + if (DulkirConfig.configOptions.dynamicKey.code == event.key) { + if (event.key == prevCode && System.currentTimeMillis() - lastCommandHandle < 1000) + return + lastCommandHandle = System.currentTimeMillis() + prevCode = event.key + TextUtils.sendCommand(DynamicKeyCommand.command.trimStart('/')) + } } } \ No newline at end of file -- cgit