Skip to content

Commit

Permalink
Add more logging when event filtering fails
Browse files Browse the repository at this point in the history
  • Loading branch information
FluxCapacitor2 committed Mar 11, 2024
1 parent bac1af6 commit ead3ba7
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions common/src/main/kotlin/com/bluedragonmc/server/Game.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,19 @@ abstract class Game(val name: String, val mapName: String, val mode: String? = n
}

protected val eventNode = EventNode.event("$name-$mapName-$mode", EventFilter.ALL) { event ->
when (event) {
is InstanceEvent -> ownsInstance(event.instance)
is GameEvent -> event.game === this
is PlayerSpawnEvent -> ownsInstance(event.spawnInstance) // Workaround for PlayerSpawnEvent not being an InstanceEvent
is PlayerEvent -> event.player.isActive && ownsInstance(event.player.instance ?: return@event false)
is ServerTickMonitorEvent -> true
else -> false
try {
when (event) {
is InstanceEvent -> ownsInstance(event.instance)
is GameEvent -> event.game === this
is PlayerSpawnEvent -> ownsInstance(event.spawnInstance) // Workaround for PlayerSpawnEvent not being an InstanceEvent
is PlayerEvent -> event.player.isActive && ownsInstance(event.player.instance ?: return@event false)
is ServerTickMonitorEvent -> true
else -> false
}
} catch (e: Exception) {
logger.error("Error while filtering event $event")
e.printStackTrace()
return@event false
}
}

Expand Down

0 comments on commit ead3ba7

Please sign in to comment.