mirror of
https://github.com/GayPizzaSpecifications/foundation.git
synced 2025-08-03 13:31:32 +00:00
Heimdall: Keep track of block data.
This commit is contained in:
@ -16,12 +16,14 @@ class BlockBreak(
|
||||
val playerUniqueIdentity: UUID,
|
||||
val location: Location,
|
||||
val material: Material,
|
||||
val blockData: String? = null,
|
||||
val timestamp: Instant = Instant.now()
|
||||
) : HeimdallEvent() {
|
||||
constructor(event: BlockBreakEvent) : this(
|
||||
event.player.uniqueId,
|
||||
event.block.location,
|
||||
event.block.type
|
||||
event.block.type,
|
||||
event.block.blockData.asString
|
||||
)
|
||||
|
||||
override fun store(transaction: Transaction) {
|
||||
@ -29,6 +31,7 @@ class BlockBreak(
|
||||
BlockBreakTable.insert {
|
||||
putPlayerTimedLocalEvent(it, timestamp, location, playerUniqueIdentity)
|
||||
it[block] = material.key.toString()
|
||||
it[blockData] = this@BlockBreak.blockData
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,12 +16,14 @@ class BlockPlace(
|
||||
val playerUniqueIdentity: UUID,
|
||||
val location: Location,
|
||||
val material: Material,
|
||||
val blockData: String? = null,
|
||||
val timestamp: Instant = Instant.now()
|
||||
) : HeimdallEvent() {
|
||||
constructor(event: BlockPlaceEvent) : this(
|
||||
event.player.uniqueId,
|
||||
event.block.location,
|
||||
event.block.type
|
||||
event.block.type,
|
||||
event.block.blockData.asString
|
||||
)
|
||||
|
||||
override fun store(transaction: Transaction) {
|
||||
@ -29,6 +31,7 @@ class BlockPlace(
|
||||
BlockPlaceTable.insert {
|
||||
putPlayerTimedLocalEvent(it, timestamp, location, playerUniqueIdentity)
|
||||
it[block] = material.key.toString()
|
||||
it[blockData] = this@BlockPlace.blockData
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package gay.pizza.foundation.heimdall.plugin.load
|
||||
|
||||
import gay.pizza.foundation.heimdall.export.ExportedBlock
|
||||
import gay.pizza.foundation.heimdall.load.WorldLoadFormat
|
||||
import gay.pizza.foundation.heimdall.load.WorldLoadWorld
|
||||
import org.bukkit.Location
|
||||
@ -24,7 +25,7 @@ class WorldReassembler(val plugin: Plugin, val server: Server, val format: World
|
||||
continue
|
||||
}
|
||||
|
||||
val blocksToMake = mutableListOf<Pair<Location, Material>>()
|
||||
val blocksToMake = mutableListOf<Pair<Location, ExportedBlock>>()
|
||||
|
||||
for ((x, zBlocks) in load.blocks) {
|
||||
for ((z, yBlocks) in zBlocks) {
|
||||
@ -36,7 +37,7 @@ class WorldReassembler(val plugin: Plugin, val server: Server, val format: World
|
||||
continue
|
||||
}
|
||||
|
||||
blocksToMake.add(Location(world, x.toDouble(), y.toDouble(), z.toDouble()) to material)
|
||||
blocksToMake.add(Location(world, x.toDouble(), y.toDouble(), z.toDouble()) to block)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -50,9 +51,15 @@ class WorldReassembler(val plugin: Plugin, val server: Server, val format: World
|
||||
val copy = section.toList()
|
||||
val runnable = object : BukkitRunnable() {
|
||||
override fun run() {
|
||||
for ((location, material) in copy) {
|
||||
for ((location, blk) in copy) {
|
||||
val block = world.getBlockAt(location)
|
||||
block.type = material
|
||||
val blockData = if (blk.data != null) server.createBlockData(blk.data!!) else null
|
||||
if (blockData != null) {
|
||||
block.blockData = blockData
|
||||
} else {
|
||||
val material = Material.matchMaterial(blk.type)!!
|
||||
block.type = material
|
||||
}
|
||||
count.incrementAndGet()
|
||||
}
|
||||
feedback("Placed ${count.get()} blocks in ${world.name}")
|
||||
|
@ -126,12 +126,6 @@ create table if not exists entity_kills (
|
||||
--
|
||||
select create_hypertable('entity_kills', 'time', 'player', 4, if_not_exists => TRUE);
|
||||
--
|
||||
create or replace view block_changes as
|
||||
select true as break, *
|
||||
from block_breaks
|
||||
union all
|
||||
select false as break, * from block_places;
|
||||
--
|
||||
create or replace view player_names as
|
||||
with unique_player_ids as (
|
||||
select distinct player
|
||||
@ -145,3 +139,14 @@ create or replace view player_names as
|
||||
limit 1
|
||||
) as name
|
||||
from unique_player_ids;
|
||||
--
|
||||
alter table block_places add column if not exists block_data text null;
|
||||
--
|
||||
alter table block_breaks add column if not exists block_data text null;
|
||||
--
|
||||
create or replace view block_changes as
|
||||
select true as break, *
|
||||
from block_breaks
|
||||
union all
|
||||
select false as break, * from block_places;
|
||||
--
|
||||
|
Reference in New Issue
Block a user