mirror of
https://github.com/GayPizzaSpecifications/foundation.git
synced 2025-08-03 13:31:32 +00:00
Gjallarhorn: Start support for player position changelogs and rename replay-block-log to block-changes
This commit is contained in:
@ -24,7 +24,7 @@ import java.util.concurrent.ConcurrentHashMap
|
|||||||
import java.util.concurrent.ScheduledThreadPoolExecutor
|
import java.util.concurrent.ScheduledThreadPoolExecutor
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
class BlockLogReplay : CliktCommand("Replay Block Logs", name = "replay-block-log") {
|
class BlockChangeCommand : CliktCommand("Block Changes", name = "block-changes") {
|
||||||
private val db by requireObject<Database>()
|
private val db by requireObject<Database>()
|
||||||
private val exactTimeAsString by option("--time", help = "Replay Time")
|
private val exactTimeAsString by option("--time", help = "Replay Time")
|
||||||
private val timelapseMode by option("--timelapse", help = "Timelapse Mode").enum<TimelapseMode> { it.id }
|
private val timelapseMode by option("--timelapse", help = "Timelapse Mode").enum<TimelapseMode> { it.id }
|
||||||
@ -36,7 +36,7 @@ class BlockLogReplay : CliktCommand("Replay Block Logs", name = "replay-block-lo
|
|||||||
private val fromCoordinate by option("--trim-from", help = "Trim From Coordinate")
|
private val fromCoordinate by option("--trim-from", help = "Trim From Coordinate")
|
||||||
private val toCoordinate by option("--trim-to", help = "Trim To Coordinate")
|
private val toCoordinate by option("--trim-to", help = "Trim To Coordinate")
|
||||||
|
|
||||||
private val logger = LoggerFactory.getLogger(BlockLogReplay::class.java)
|
private val logger = LoggerFactory.getLogger(BlockChangeCommand::class.java)
|
||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (timelapseMode != null) {
|
if (timelapseMode != null) {
|
||||||
@ -72,9 +72,9 @@ class BlockLogReplay : CliktCommand("Replay Block Logs", name = "replay-block-lo
|
|||||||
}
|
}
|
||||||
logger.info("State Tracking Completed")
|
logger.info("State Tracking Completed")
|
||||||
val allBlockOffsets = trackers.map { it.value.calculateZeroBlockOffset() }
|
val allBlockOffsets = trackers.map { it.value.calculateZeroBlockOffset() }
|
||||||
val globalBlockOffset = BlockCoordinate.maxOf(allBlockOffsets.asSequence())
|
val globalBlockOffset = BlockCoordinate.maxOf(allBlockOffsets)
|
||||||
val allBlockMaxes = trackers.map { it.value.calculateMaxBlock() }
|
val allBlockMaxes = trackers.map { it.value.calculateMaxBlock() }
|
||||||
val globalBlockMax = BlockCoordinate.maxOf(allBlockMaxes.asSequence())
|
val globalBlockMax = BlockCoordinate.maxOf(allBlockMaxes)
|
||||||
val globalBlockExpanse = BlockExpanse.offsetAndMax(globalBlockOffset, globalBlockMax)
|
val globalBlockExpanse = BlockExpanse.offsetAndMax(globalBlockOffset, globalBlockMax)
|
||||||
|
|
||||||
logger.info("Calculations Completed")
|
logger.info("Calculations Completed")
|
@ -1,12 +1,12 @@
|
|||||||
package cloud.kubelet.foundation.gjallarhorn
|
package cloud.kubelet.foundation.gjallarhorn
|
||||||
|
|
||||||
import cloud.kubelet.foundation.gjallarhorn.commands.BlockLogReplay
|
import cloud.kubelet.foundation.gjallarhorn.commands.BlockChangeCommand
|
||||||
import cloud.kubelet.foundation.gjallarhorn.commands.PlayerPositionExport
|
import cloud.kubelet.foundation.gjallarhorn.commands.PlayerPositionExport
|
||||||
import cloud.kubelet.foundation.gjallarhorn.commands.PlayerSessionExport
|
import cloud.kubelet.foundation.gjallarhorn.commands.PlayerSessionExport
|
||||||
import com.github.ajalt.clikt.core.subcommands
|
import com.github.ajalt.clikt.core.subcommands
|
||||||
|
|
||||||
fun main(args: Array<String>) = GjallarhornCommand().subcommands(
|
fun main(args: Array<String>) = GjallarhornCommand().subcommands(
|
||||||
BlockLogReplay(),
|
BlockChangeCommand(),
|
||||||
PlayerSessionExport(),
|
PlayerSessionExport(),
|
||||||
PlayerPositionExport()
|
PlayerPositionExport()
|
||||||
).main(args)
|
).main(args)
|
||||||
|
@ -26,7 +26,7 @@ data class BlockCoordinate(
|
|||||||
companion object {
|
companion object {
|
||||||
val zero = BlockCoordinate(0, 0, 0)
|
val zero = BlockCoordinate(0, 0, 0)
|
||||||
|
|
||||||
fun maxOf(coordinates: Sequence<BlockCoordinate>): BlockCoordinate {
|
fun maxOf(coordinates: List<BlockCoordinate>): BlockCoordinate {
|
||||||
val x = coordinates.maxOf { it.x }
|
val x = coordinates.maxOf { it.x }
|
||||||
val y = coordinates.maxOf { it.y }
|
val y = coordinates.maxOf { it.y }
|
||||||
val z = coordinates.maxOf { it.z }
|
val z = coordinates.maxOf { it.z }
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
package cloud.kubelet.foundation.gjallarhorn.state
|
||||||
|
|
||||||
|
import java.time.Instant
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
data class PlayerPositionChange(
|
||||||
|
val time: Instant,
|
||||||
|
val player: UUID,
|
||||||
|
val world: UUID,
|
||||||
|
val x: Double,
|
||||||
|
val y: Double,
|
||||||
|
val z: Double,
|
||||||
|
val pitch: Double,
|
||||||
|
val yaw: Double
|
||||||
|
)
|
@ -0,0 +1,28 @@
|
|||||||
|
package cloud.kubelet.foundation.gjallarhorn.state
|
||||||
|
|
||||||
|
import cloud.kubelet.foundation.heimdall.table.PlayerPositionTable
|
||||||
|
import org.jetbrains.exposed.sql.Database
|
||||||
|
import org.jetbrains.exposed.sql.Op
|
||||||
|
import org.jetbrains.exposed.sql.select
|
||||||
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
|
|
||||||
|
class PlayerPositionChangelog(
|
||||||
|
val changes: List<PlayerPositionChange>
|
||||||
|
) {
|
||||||
|
companion object {
|
||||||
|
fun query(db: Database, filter: Op<Boolean> = Op.TRUE): PlayerPositionChangelog = transaction(db) {
|
||||||
|
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)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user