From 452ec0d7da55aecb94cf6acfc629a7fb43e66f8e Mon Sep 17 00:00:00 2001 From: Alex Zenla Date: Sat, 28 Jan 2023 22:11:57 -0800 Subject: [PATCH] Fix code warings. --- .../commands/BlockChangeTimelapseCommand.kt | 15 +++++++-------- .../tool/commands/ChunkExportLoaderCommand.kt | 13 ++++++------- .../tool/commands/PlayerPositionExport.kt | 6 +++--- .../tool/commands/PlayerSessionExport.kt | 14 +++++++------- .../heimdall/tool/export/ChunkExportLoader.kt | 2 +- .../tool/render/PlayerLocationShareRenderer.kt | 14 +++++++------- .../heimdall/tool/state/BlockChangelog.kt | 6 +++--- .../tool/state/PlayerPositionChangelog.kt | 18 +++++++++--------- 8 files changed, 43 insertions(+), 45 deletions(-) diff --git a/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/commands/BlockChangeTimelapseCommand.kt b/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/commands/BlockChangeTimelapseCommand.kt index fe34aed..895430e 100644 --- a/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/commands/BlockChangeTimelapseCommand.kt +++ b/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/commands/BlockChangeTimelapseCommand.kt @@ -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) diff --git a/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/commands/ChunkExportLoaderCommand.kt b/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/commands/ChunkExportLoaderCommand.kt index 3c109ca..2823218 100644 --- a/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/commands/ChunkExportLoaderCommand.kt +++ b/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/commands/ChunkExportLoaderCommand.kt @@ -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 diff --git a/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/commands/PlayerPositionExport.kt b/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/commands/PlayerPositionExport.kt index dfcd84d..3848882 100644 --- a/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/commands/PlayerPositionExport.kt +++ b/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/commands/PlayerPositionExport.kt @@ -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") diff --git a/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/commands/PlayerSessionExport.kt b/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/commands/PlayerSessionExport.kt index c9fd923..2eae802 100644 --- a/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/commands/PlayerSessionExport.kt +++ b/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/commands/PlayerSessionExport.kt @@ -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}") } diff --git a/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/export/ChunkExportLoader.kt b/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/export/ChunkExportLoader.kt index b30b630..342ea3c 100644 --- a/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/export/ChunkExportLoader.kt +++ b/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/export/ChunkExportLoader.kt @@ -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() else null diff --git a/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/render/PlayerLocationShareRenderer.kt b/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/render/PlayerLocationShareRenderer.kt index 5e74639..a8c6e8f 100644 --- a/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/render/PlayerLocationShareRenderer.kt +++ b/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/render/PlayerLocationShareRenderer.kt @@ -25,15 +25,15 @@ class PlayerLocationShareRenderer( val playerSparseMap = BlockCoordinateSparseMap>() val allPlayerIds = HashSet() 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) }, diff --git a/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/state/BlockChangelog.kt b/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/state/BlockChangelog.kt index b176468..1b3cc10 100644 --- a/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/state/BlockChangelog.kt +++ b/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/state/BlockChangelog.kt @@ -60,9 +60,9 @@ class BlockChangelog( companion object { fun query(db: Database, filter: Op = 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] diff --git a/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/state/PlayerPositionChangelog.kt b/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/state/PlayerPositionChangelog.kt index c7d7204..67a7d36 100644 --- a/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/state/PlayerPositionChangelog.kt +++ b/tool-gjallarhorn/src/main/kotlin/gay/pizza/foundation/heimdall/tool/state/PlayerPositionChangelog.kt @@ -11,15 +11,15 @@ class PlayerPositionChangelog( ) { companion object { fun query(db: Database, filter: Op = 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) })