[enhancement] Disable AutoMine on Baritone cancel command

This commit is contained in:
Xiaro 2020-11-29 15:11:14 -05:00
parent 2cfb55f495
commit 0ead2f23eb
No known key found for this signature in database
GPG Key ID: 996D265D6E155377
1 changed files with 19 additions and 12 deletions

View File

@ -1,6 +1,7 @@
package me.zeroeightsix.kami.module.modules.misc package me.zeroeightsix.kami.module.modules.misc
import me.zeroeightsix.kami.command.Command import me.zeroeightsix.kami.command.Command
import me.zeroeightsix.kami.event.events.BaritoneCommandEvent
import me.zeroeightsix.kami.event.events.ConnectionEvent import me.zeroeightsix.kami.event.events.ConnectionEvent
import me.zeroeightsix.kami.event.events.SafeTickEvent import me.zeroeightsix.kami.event.events.SafeTickEvent
import me.zeroeightsix.kami.mixin.extension.sendClickBlockToController import me.zeroeightsix.kami.mixin.extension.sendClickBlockToController
@ -33,6 +34,10 @@ object AutoMine : Module() {
} }
} }
override fun onDisable() {
BaritoneUtils.cancelEverything()
}
private fun run() { private fun run() {
if (mc.player == null || isDisabled || manual.value) return if (mc.player == null || isDisabled || manual.value) return
@ -56,19 +61,7 @@ object AutoMine : Module() {
MessageSendHelper.sendBaritoneCommand("mine", *blocks.toTypedArray()) MessageSendHelper.sendBaritoneCommand("mine", *blocks.toTypedArray())
} }
override fun onDisable() {
BaritoneUtils.cancelEverything()
}
init { init {
with(Setting.SettingListeners { run() }) {
iron.settingListener = this
diamond.settingListener = this
gold.settingListener = this
coal.settingListener = this
log.settingListener = this
}
listener<SafeTickEvent> { listener<SafeTickEvent> {
if (manual.value) { if (manual.value) {
mc.sendClickBlockToController(true) mc.sendClickBlockToController(true)
@ -78,5 +71,19 @@ object AutoMine : Module() {
listener<ConnectionEvent.Disconnect> { listener<ConnectionEvent.Disconnect> {
disable() disable()
} }
listener<BaritoneCommandEvent> { event ->
if (event.command.names.any { it.contains("cancel") }) {
disable()
}
}
with(Setting.SettingListeners { run() }) {
iron.settingListener = this
diamond.settingListener = this
gold.settingListener = this
coal.settingListener = this
log.settingListener = this
}
} }
} }