aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/dulkirfabric/features/KeyShortCutImpl.kt
blob: c94c258e0f8518f3f6132d4a2ef44f8770a849c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package com.dulkirfabric.features

import com.dulkirfabric.config.DulkirConfig
import com.dulkirfabric.events.WorldKeyPressEvent
import com.dulkirfabric.util.TextUtils
import meteordevelopment.orbit.EventHandler

object KeyShortCutImpl {
    @EventHandler
    fun onKeyPress(event: WorldKeyPressEvent) {
        DulkirConfig.configOptions.macrosList.forEach {
            if (it.keyBinding.code == event.key) {
                // This conditional allows for these shortcuts to work for commands or normal messages
                if (it.command.startsWith("/"))
                    TextUtils.sendCommand(it.command.substring(1))
                else
                    TextUtils.sendMessage(it.command)
            }
        }
    }
}