Skip to content

Commit 60b57a4

Browse files
authored
Hide warnings from managers unless enabled (#186)
1 parent e715dc0 commit 60b57a4

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
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
2425
import com.lambda.interaction.managers.PostActionHandler
2526
import com.lambda.interaction.managers.interacting.InteractManager.placeSound
2627
import com.lambda.threading.runSafe
2728
import com.lambda.util.BlockUtils.matches
28-
import com.lambda.util.Communication.info
2929
import com.lambda.util.Communication.warn
3030
import com.lambda.util.collections.LimitedDecayQueue
3131

@@ -34,7 +34,7 @@ object InteractedBlockHandler : PostActionHandler<InteractInfo>() {
3434
DEFAULT.buildConfig.maxPendingActions,
3535
DEFAULT.buildConfig.actionTimeout * 50L
3636
) {
37-
info("${it::class.simpleName} at ${it.context.blockPos.toShortString()} timed out")
37+
if (managerDebugLogs) warn("${it::class.simpleName} at ${it.context.blockPos.toShortString()} timed out")
3838
if (it.interactConfig.interactConfirmationMode != InteractConfig.InteractConfirmationMode.AwaitThenPlace) {
3939
runSafe {
4040
world.setBlockState(it.context.blockPos, it.context.cachedState)
@@ -60,7 +60,7 @@ object InteractedBlockHandler : PostActionHandler<InteractInfo>() {
6060

6161
pending.stopPending()
6262

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

0 commit comments

Comments
 (0)