Fix code warings.

This commit is contained in:
Alex Zenla 2023-01-28 22:11:57 -08:00
parent b653c179b7
commit 452ec0d7da
Signed by: alex
GPG Key ID: C0780728420EBFE5
8 changed files with 43 additions and 45 deletions

View File

@ -1,9 +1,5 @@
package gay.pizza.foundation.heimdall.tool.commands
import gay.pizza.foundation.heimdall.tool.render.*
import gay.pizza.foundation.heimdall.tool.state.*
import gay.pizza.foundation.heimdall.tool.util.compose
import gay.pizza.foundation.heimdall.tool.util.savePngFile
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.requireObject
import com.github.ajalt.clikt.parameters.options.default
@ -12,6 +8,9 @@ import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.options.required
import com.github.ajalt.clikt.parameters.types.enum
import com.github.ajalt.clikt.parameters.types.int
import gay.pizza.foundation.heimdall.tool.render.*
import gay.pizza.foundation.heimdall.tool.state.*
import gay.pizza.foundation.heimdall.tool.util.compose
import gay.pizza.foundation.heimdall.view.BlockChangeView
import org.jetbrains.exposed.sql.Database
import org.jetbrains.exposed.sql.SqlExpressionBuilder.greaterEq
@ -75,10 +74,10 @@ class BlockChangeTimelapseCommand : CliktCommand("Block Change Timelapse", name
val trim = maybeBuildTrim()
val filter = compose(
combine = { a, b -> a and b },
{ trim?.first?.x != null } to { gay.pizza.foundation.heimdall.view.BlockChangeView.x greaterEq trim!!.first.x },
{ trim?.first?.z != null } to { gay.pizza.foundation.heimdall.view.BlockChangeView.z greaterEq trim!!.first.z },
{ trim?.second?.x != null } to { gay.pizza.foundation.heimdall.view.BlockChangeView.x lessEq trim!!.second.x },
{ trim?.second?.z != null } to { gay.pizza.foundation.heimdall.view.BlockChangeView.z lessEq trim!!.second.z }
{ trim?.first?.x != null } to { BlockChangeView.x greaterEq trim!!.first.x },
{ trim?.first?.z != null } to { BlockChangeView.z greaterEq trim!!.first.z },
{ trim?.second?.x != null } to { BlockChangeView.x lessEq trim!!.second.x },
{ trim?.second?.z != null } to { BlockChangeView.z lessEq trim!!.second.z }
)
val changelog = BlockChangelog.query(db, filter)

View File

@ -1,11 +1,5 @@
package gay.pizza.foundation.heimdall.tool.commands
import gay.pizza.foundation.heimdall.tool.export.ChunkExportLoader
import gay.pizza.foundation.heimdall.tool.export.CombinedChunkFormat
import gay.pizza.foundation.heimdall.tool.state.BlockExpanse
import gay.pizza.foundation.heimdall.tool.state.BlockLogTracker
import gay.pizza.foundation.heimdall.tool.state.ChangelogSlice
import gay.pizza.foundation.heimdall.tool.util.savePngFile
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.requireObject
import com.github.ajalt.clikt.parameters.arguments.argument
@ -14,7 +8,12 @@ import com.github.ajalt.clikt.parameters.options.option
import com.github.ajalt.clikt.parameters.types.enum
import com.github.ajalt.clikt.parameters.types.int
import com.github.ajalt.clikt.parameters.types.path
import kotlinx.serialization.ExperimentalSerializationApi
import gay.pizza.foundation.heimdall.tool.export.ChunkExportLoader
import gay.pizza.foundation.heimdall.tool.export.CombinedChunkFormat
import gay.pizza.foundation.heimdall.tool.state.BlockExpanse
import gay.pizza.foundation.heimdall.tool.state.BlockLogTracker
import gay.pizza.foundation.heimdall.tool.state.ChangelogSlice
import gay.pizza.foundation.heimdall.tool.util.savePngFile
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.decodeFromStream
import kotlinx.serialization.json.encodeToStream

View File

@ -25,9 +25,9 @@ class PlayerPositionExport : CliktCommand(name = "export-player-positions", help
override fun run() {
val filter = compose(
combine = { a, b -> a and b },
{ startTimeString != null } to { gay.pizza.foundation.heimdall.table.PlayerPositionTable.time greaterEq Instant.parse(startTimeString) },
{ endTimeString != null } to { gay.pizza.foundation.heimdall.table.PlayerPositionTable.time lessEq Instant.parse(endTimeString) },
{ playerIdString != null } to { gay.pizza.foundation.heimdall.table.PlayerPositionTable.player eq UUID.fromString(playerIdString) }
{ startTimeString != null } to { PlayerPositionTable.time greaterEq Instant.parse(startTimeString) },
{ endTimeString != null } to { PlayerPositionTable.time lessEq Instant.parse(endTimeString) },
{ playerIdString != null } to { PlayerPositionTable.player eq UUID.fromString(playerIdString) }
)
println("time,player,world,x,y,z,pitch,yaw")

View File

@ -21,18 +21,18 @@ class PlayerSessionExport : CliktCommand(name = "export-player-sessions", help =
override fun run() {
val filter = compose(
combine = { a, b -> a and b },
{ playerIdString != null } to { gay.pizza.foundation.heimdall.table.PlayerSessionTable.player eq UUID.fromString(playerIdString) },
{ playerNameString != null } to { gay.pizza.foundation.heimdall.table.PlayerSessionTable.name eq playerNameString!! }
{ playerIdString != null } to { PlayerSessionTable.player eq UUID.fromString(playerIdString) },
{ playerNameString != null } to { PlayerSessionTable.name eq playerNameString!! }
)
println("id,player,name,start,end")
transaction(db) {
gay.pizza.foundation.heimdall.table.PlayerSessionTable.select(filter).orderBy(gay.pizza.foundation.heimdall.table.PlayerSessionTable.endTime).forEach { row ->
PlayerSessionTable.select(filter).orderBy(PlayerSessionTable.endTime).forEach { row ->
val id = row[gay.pizza.foundation.heimdall.table.PlayerSessionTable.id]
val player = row[gay.pizza.foundation.heimdall.table.PlayerSessionTable.player]
val name = row[gay.pizza.foundation.heimdall.table.PlayerSessionTable.name]
val start = row[gay.pizza.foundation.heimdall.table.PlayerSessionTable.startTime]
val end = row[gay.pizza.foundation.heimdall.table.PlayerSessionTable.endTime]
val player = row[PlayerSessionTable.player]
val name = row[PlayerSessionTable.name]
val start = row[PlayerSessionTable.startTime]
val end = row[PlayerSessionTable.endTime]
println("${id},${player},${name},${start},${end}")
}

View File

@ -33,7 +33,7 @@ class ChunkExportLoader(
fun loadChunkFile(path: Path, id: Int = 0) {
val fileInputStream = path.inputStream()
val gzipInputStream = GZIPInputStream(fileInputStream)
val chunk = Json.decodeFromStream(gay.pizza.foundation.heimdall.export.ExportedChunk.serializer(), gzipInputStream)
val chunk = Json.decodeFromStream(ExportedChunk.serializer(), gzipInputStream)
var blockCount = 0L
val allBlocks = if (tracker != null) mutableMapOf<BlockCoordinate, BlockState>() else null

View File

@ -25,15 +25,15 @@ class PlayerLocationShareRenderer(
val playerSparseMap = BlockCoordinateSparseMap<MutableList<UUID>>()
val allPlayerIds = HashSet<UUID>()
transaction(db) {
gay.pizza.foundation.heimdall.table.PlayerPositionTable.select {
(gay.pizza.foundation.heimdall.table.PlayerPositionTable.time greater start) and
(gay.pizza.foundation.heimdall.table.PlayerPositionTable.time lessEq end)
PlayerPositionTable.select {
(PlayerPositionTable.time greater start) and
(PlayerPositionTable.time lessEq end)
}.forEach {
val x = it[gay.pizza.foundation.heimdall.table.PlayerPositionTable.x].toLong()
val y = it[gay.pizza.foundation.heimdall.table.PlayerPositionTable.y].toLong()
val z = it[gay.pizza.foundation.heimdall.table.PlayerPositionTable.z].toLong()
val x = it[PlayerPositionTable.x].toLong()
val y = it[PlayerPositionTable.y].toLong()
val z = it[PlayerPositionTable.z].toLong()
val coordinate = expanse.offset.applyAsOffset(BlockCoordinate(x, y, z))
val player = it[gay.pizza.foundation.heimdall.table.PlayerPositionTable.player]
val player = it[PlayerPositionTable.player]
playerSparseMap.createOrModify(
coordinate,
create = { mutableListOf(player) },

View File

@ -60,9 +60,9 @@ class BlockChangelog(
companion object {
fun query(db: Database, filter: Op<Boolean> = Op.TRUE): BlockChangelog = transaction(db) {
BlockChangelog(gay.pizza.foundation.heimdall.view.BlockChangeView.select(filter).orderBy(gay.pizza.foundation.heimdall.view.BlockChangeView.time).map { row ->
val time = row[gay.pizza.foundation.heimdall.view.BlockChangeView.time]
val changeIsBreak = row[gay.pizza.foundation.heimdall.view.BlockChangeView.isBreak]
BlockChangelog(BlockChangeView.select(filter).orderBy(BlockChangeView.time).map { row ->
val time = row[BlockChangeView.time]
val changeIsBreak = row[BlockChangeView.isBreak]
val x = row[gay.pizza.foundation.heimdall.view.BlockChangeView.x]
val y = row[gay.pizza.foundation.heimdall.view.BlockChangeView.y]
val z = row[gay.pizza.foundation.heimdall.view.BlockChangeView.z]

View File

@ -11,15 +11,15 @@ class PlayerPositionChangelog(
) {
companion object {
fun query(db: Database, filter: Op<Boolean> = Op.TRUE): PlayerPositionChangelog = transaction(db) {
PlayerPositionChangelog(gay.pizza.foundation.heimdall.table.PlayerPositionTable.select(filter).orderBy(gay.pizza.foundation.heimdall.table.PlayerPositionTable.time).map { row ->
val time = row[gay.pizza.foundation.heimdall.table.PlayerPositionTable.time]
val player = row[gay.pizza.foundation.heimdall.table.PlayerPositionTable.player]
val world = row[gay.pizza.foundation.heimdall.table.PlayerPositionTable.world]
val x = row[gay.pizza.foundation.heimdall.table.PlayerPositionTable.x]
val y = row[gay.pizza.foundation.heimdall.table.PlayerPositionTable.y]
val z = row[gay.pizza.foundation.heimdall.table.PlayerPositionTable.z]
val pitch = row[gay.pizza.foundation.heimdall.table.PlayerPositionTable.z]
val yaw = row[gay.pizza.foundation.heimdall.table.PlayerPositionTable.z]
PlayerPositionChangelog(PlayerPositionTable.select(filter).orderBy(PlayerPositionTable.time).map { row ->
val time = row[PlayerPositionTable.time]
val player = row[PlayerPositionTable.player]
val world = row[PlayerPositionTable.world]
val x = row[PlayerPositionTable.x]
val y = row[PlayerPositionTable.y]
val z = row[PlayerPositionTable.z]
val pitch = row[PlayerPositionTable.z]
val yaw = row[PlayerPositionTable.z]
PlayerPositionChange(time, player, world, x, y, z, pitch, yaw)
})