25 lines
892 B
Kotlin
25 lines
892 B
Kotlin
package codes.som.hibiscus.util.command
|
|
|
|
import codes.som.hibiscus.HibiscusLog
|
|
import codes.som.hibiscus.Hibiscus
|
|
import codes.som.hibiscus.api.command.CommandContext
|
|
import codes.som.hibiscus.api.command.exceptions.CommandExecutionException
|
|
import codes.som.hibiscus.api.event.TypedListener
|
|
import codes.som.hibiscus.events.SendChatEvent
|
|
|
|
class ChatCommandListener : TypedListener<SendChatEvent>(SendChatEvent::class.java) {
|
|
override fun on(event: SendChatEvent) {
|
|
if (event.message.startsWith(".")) {
|
|
try {
|
|
Hibiscus.commands.context = CommandContext.MANUAL
|
|
Hibiscus.commands.executeCommand(event.message.substring(1))
|
|
} catch (e: CommandExecutionException) {
|
|
// e.printStackTrace()
|
|
e.cause?.message?.let { HibiscusLog.error(it) }
|
|
}
|
|
|
|
event.cancel()
|
|
}
|
|
}
|
|
}
|