Gjallarhorn: Graphical render session fix for frame not closing.

This commit is contained in:
Kenneth Endfinger 2022-02-25 00:17:05 -05:00
parent c9d4fe1733
commit 8289616762
No known key found for this signature in database
GPG Key ID: C4E68E5647420E10
8 changed files with 12 additions and 31 deletions

View File

@ -1,7 +1,5 @@
package cloud.kubelet.foundation.heimdall
import org.bukkit.Material
fun String.sqlSplitStatements(): List<String> {
val statements = mutableListOf<String>()
val buffer = StringBuilder()
@ -21,6 +19,3 @@ fun String.sqlSplitStatements(): List<String> {
flush()
return statements
}
val Material.storageBlockName: String
get() = "${key.namespace}:${key.key}"

View File

@ -1,6 +1,5 @@
package cloud.kubelet.foundation.heimdall.event
import cloud.kubelet.foundation.heimdall.storageBlockName
import cloud.kubelet.foundation.heimdall.table.BlockBreakTable
import org.bukkit.Location
import org.bukkit.Material
@ -29,7 +28,7 @@ class BlockBreak(
it[z] = location.z
it[pitch] = location.pitch.toDouble()
it[yaw] = location.yaw.toDouble()
it[block] = material.storageBlockName
it[block] = material.key.toString()
}
}
}

View File

@ -1,6 +1,5 @@
package cloud.kubelet.foundation.heimdall.event
import cloud.kubelet.foundation.heimdall.storageBlockName
import cloud.kubelet.foundation.heimdall.table.BlockPlaceTable
import org.bukkit.Location
import org.bukkit.Material
@ -29,7 +28,7 @@ class BlockPlace(
it[z] = location.z
it[pitch] = location.pitch.toDouble()
it[yaw] = location.yaw.toDouble()
it[block] = material.storageBlockName
it[block] = material.key.toString()
}
}
}

View File

@ -22,7 +22,7 @@ class ChunkExportLoader(
chunkFiles = chunkFiles.take(limit)
}
if (fast) {
chunkFiles.parallelStream().forEach { loadChunkFile(it, id = chunkFiles.indexOf(it)) }
chunkFiles.withIndex().toList().parallelStream().forEach { loadChunkFile(it.value, id = it.index) }
} else {
for (filePath in chunkFiles) {
loadChunkFile(filePath, id = chunkFiles.indexOf(filePath))

View File

@ -5,11 +5,16 @@ import cloud.kubelet.foundation.gjallarhorn.state.BlockExpanse
import cloud.kubelet.foundation.gjallarhorn.state.BlockStateMap
import cloud.kubelet.foundation.gjallarhorn.state.ChangelogSlice
import java.awt.image.BufferedImage
import javax.swing.WindowConstants
class LaunchGraphicalRenderSession(val expanse: BlockExpanse) : BlockImageRenderer {
override fun render(slice: ChangelogSlice, map: BlockStateMap): BufferedImage {
val session = GraphicalRenderSession(expanse, map)
session.isVisible = true
session.defaultCloseOperation = WindowConstants.HIDE_ON_CLOSE
while (session.isVisible) {
Thread.sleep(1000)
}
return BufferedImage(1, 1, BufferedImage.TYPE_3BYTE_BGR)
}
}

View File

@ -1,5 +1,8 @@
package cloud.kubelet.foundation.gjallarhorn.state
import kotlinx.serialization.Serializable
@Serializable
enum class BlockChangeType {
Place,
Break

View File

@ -1,21 +0,0 @@
package cloud.kubelet.foundation.gjallarhorn.state
class BlockLogTrackerStateMap(val tracker: BlockLogTracker) : BlockStateMap {
override fun get(position: BlockCoordinate): BlockState? = tracker.get(position)
override fun getVerticalSection(x: Long, z: Long): Map<Long, BlockState> {
return tracker.blocks.filter { it.key.x == x && it.key.z == z }.mapKeys { it.key.y }
}
override fun getXSection(x: Long): Map<Long, Map<Long, BlockState>>? {
throw RuntimeException("X section not supported.")
}
override fun put(position: BlockCoordinate, value: BlockState) {
throw RuntimeException("Modification not supported.")
}
override fun createOrModify(position: BlockCoordinate, create: () -> BlockState, modify: (BlockState) -> Unit) {
throw RuntimeException("Modification not supported.")
}
}

View File

@ -6,6 +6,7 @@ fun compose(
combine: (Op<Boolean>, Op<Boolean>) -> Op<Boolean>,
vararg filters: Pair<() -> Boolean, () -> Op<Boolean>>
): Op<Boolean> = filters.toMap().entries
.asSequence()
.filter { it.key() }
.map { it.value() }
.fold(Op.TRUE as Op<Boolean>, combine)