aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt
diff options
context:
space:
mode:
authoringlettronald <inglettronald@gmail.com>2023-06-30 03:55:49 -0500
committeringlettronald <inglettronald@gmail.com>2023-06-30 03:55:49 -0500
commitcd7b08b4799b5ee08f1dca6ff92a28e74d9db102 (patch)
tree86691df35e72dc3d4e15891f049e1edbc8a2bc3a /src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt
parentf01846879e226b932d81fa842e4eee4567f0a28c (diff)
downloadDulkirMod-Fabric-cd7b08b4799b5ee08f1dca6ff92a28e74d9db102.tar.gz
DulkirMod-Fabric-cd7b08b4799b5ee08f1dca6ff92a28e74d9db102.tar.bz2
DulkirMod-Fabric-cd7b08b4799b5ee08f1dca6ff92a28e74d9db102.zip
Added Alias Code And Implemented Dynamic Key
Diffstat (limited to 'src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt')
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt17
1 files changed, 10 insertions, 7 deletions
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