[enhancement] Added option to StashLogger to Disable AutoWalk/Cancels Baritone on stash found

closes #1794
This commit is contained in:
Xiaro 2021-01-11 17:28:10 -05:00
parent 1facfed7e6
commit 7e763ffb2f
No known key found for this signature in database
GPG Key ID: 996D265D6E155377
1 changed files with 39 additions and 23 deletions

View File

@ -4,7 +4,9 @@ import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.launch
import me.zeroeightsix.kami.manager.managers.WaypointManager
import me.zeroeightsix.kami.module.Module
import me.zeroeightsix.kami.module.modules.movement.AutoWalk
import me.zeroeightsix.kami.setting.ModuleConfig.setting
import me.zeroeightsix.kami.util.BaritoneUtils
import me.zeroeightsix.kami.util.TickTimer
import me.zeroeightsix.kami.util.TimeUnit
import me.zeroeightsix.kami.util.math.CoordinateConverter.asString
@ -42,6 +44,8 @@ object StashLogger : Module(
private val dispenserDensity by setting("MinDispensers", 5, 1..20, 1, { logDispensers })
private val logHoppers by setting("Hoppers", true)
private val hopperDensity by setting("MinHoppers", 5, 1..20, 1, { logHoppers })
private val disableAutoWalk by setting("DisableAutoWalk", false, description = "Disables AutoWalk when a stash is found")
private val cancelBaritone by setting("CancelBaritone", false, description = "Cancels Baritone when a stash is found")
private val chunkData = LinkedHashMap<Long, ChunkStats>()
private val knownPositions = HashSet<BlockPos>()
@ -55,6 +59,15 @@ object StashLogger : Module(
coroutineScope {
launch {
world.loadedTileEntityList.toList().forEach(::logTileEntity)
notification()
}
}
}
}
}
private fun notification() {
var found = false
for (chunkStats in chunkData.values) {
if (!chunkStats.hot) continue
@ -77,10 +90,13 @@ object StashLogger : Module(
val positionString = center.asString()
MessageSendHelper.sendChatMessage("$chatName $positionString $string")
}
found = found || true
}
}
}
}
if (found) {
if (disableAutoWalk && AutoWalk.isEnabled) AutoWalk.disable()
if (cancelBaritone && (BaritoneUtils.isPathing || BaritoneUtils.isActive)) BaritoneUtils.cancelEverything()
}
}