Skip to content

Commit f2426a7

Browse files
committed
manager debug logs setting and checks
1 parent 0ff69be commit f2426a7

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/main/kotlin/com/lambda/config/AutomationConfig.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ open class AutomationConfig(
6262
name: String = module.name,
6363
edits: (AutomationConfig.() -> Unit)? = null
6464
) {
65-
defaultAutomationConfig = AutomationConfig("$name Automation Config").apply { edits?.invoke(this) }
65+
this.defaultAutomationConfig = AutomationConfig("$name Automation Config").apply { edits?.invoke(this) }
6666
}
6767

6868
fun MutableAutomationConfig.setDefaultAutomationConfig(
@@ -79,6 +79,7 @@ open class AutomationConfig(
7979
val showAllEntries by setting("Show All Entries", false, "Show all entries in the task tree").group(Group.Debug)
8080
val shrinkFactor by setting("Shrink Factor", 0.001, 0.0..1.0, 0.001).group(Group.Debug)
8181
val ignoreItemDropWarnings by setting("Ignore Drop Warnings", false, "Hides the item drop warnings from the break manager").group(Group.Debug)
82+
val managerDebugLogs by setting("Manager Debug Logs", false, "Prints debug logs from managers into chat").group(Group.Debug)
8283

8384
@Volatile
8485
var drawables = listOf<Drawable>()

src/main/kotlin/com/lambda/interaction/managers/breaking/BrokenBlockHandler.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package com.lambda.interaction.managers.breaking
1919

2020
import com.lambda.config.AutomationConfig.Companion.DEFAULT
21+
import com.lambda.config.AutomationConfig.Companion.DEFAULT.managerDebugLogs
2122
import com.lambda.context.SafeContext
2223
import com.lambda.event.events.EntityEvent
2324
import com.lambda.event.events.WorldEvent
@@ -60,11 +61,11 @@ object BrokenBlockHandler : PostActionHandler<BreakInfo>() {
6061
if (!info.broken) {
6162
val message = "${info.type} ${info::class.simpleName} at ${info.context.blockPos.toShortString()} timed out with cached state ${info.context.cachedState}"
6263
BreakManager.logger.error(message)
63-
warn(message)
64+
if (managerDebugLogs) this@BrokenBlockHandler.warn(message)
6465
} else if (!DEFAULT.ignoreItemDropWarnings) {
6566
val message = "${info.type} ${info::class.simpleName}'s item drop at ${info.context.blockPos.toShortString()} timed out"
66-
BreakManager.logger.warn(message)
67-
warn(message)
67+
BreakManager.logger.warning(message)
68+
if (managerDebugLogs) this@BrokenBlockHandler.warn(message)
6869
}
6970

7071
if (!info.broken && info.breakConfig.breakConfirmation != BreakConfirmationMode.AwaitThenBreak) {
@@ -97,7 +98,7 @@ object BrokenBlockHandler : PostActionHandler<BreakInfo>() {
9798
} else {
9899
val message = "Broken block at ${event.pos.toShortString()} was rejected with ${event.newState} instead of ${pending.context.cachedState.emptyState}"
99100
BreakManager.logger.error(message)
100-
this@BrokenBlockHandler.warn(message)
101+
if (managerDebugLogs) this@BrokenBlockHandler.warn(message)
101102
pending.stopPending()
102103
}
103104
return@listen

src/main/kotlin/com/lambda/interaction/managers/interacting/InteractedBlockHandler.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package com.lambda.interaction.managers.interacting
1919

2020
import com.lambda.config.AutomationConfig.Companion.DEFAULT
21+
import com.lambda.config.AutomationConfig.Companion.DEFAULT.managerDebugLogs
2122
import com.lambda.event.events.WorldEvent
2223
import com.lambda.event.listener.SafeListener.Companion.listen
2324
import com.lambda.interaction.construction.simulation.processing.ProcessorRegistry
@@ -60,7 +61,7 @@ object InteractedBlockHandler : PostActionHandler<InteractInfo>() {
6061

6162
pending.stopPending()
6263

63-
this@InteractedBlockHandler.warn("Placed block at ${event.pos.toShortString()} was rejected with ${event.newState} instead of ${pending.context.expectedState}")
64+
if (managerDebugLogs) this@InteractedBlockHandler.warn("Placed block at ${event.pos.toShortString()} was rejected with ${event.newState} instead of ${pending.context.expectedState}")
6465
return@listen
6566
}
6667

0 commit comments

Comments
 (0)