mirror of
				https://github.com/GayPizzaSpecifications/foundation.git
				synced 2025-11-04 03:39:37 +00:00 
			
		
		
		
	Gjallarhorn: Graphical render session fix for frame not closing.
This commit is contained in:
		@ -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}"
 | 
			
		||||
 | 
			
		||||
@ -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()
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -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()
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -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))
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,8 @@
 | 
			
		||||
package cloud.kubelet.foundation.gjallarhorn.state
 | 
			
		||||
 | 
			
		||||
import kotlinx.serialization.Serializable
 | 
			
		||||
 | 
			
		||||
@Serializable
 | 
			
		||||
enum class BlockChangeType {
 | 
			
		||||
  Place,
 | 
			
		||||
  Break
 | 
			
		||||
 | 
			
		||||
@ -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.")
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user