mirror of
https://github.com/GayPizzaSpecifications/foundation.git
synced 2025-08-02 21:20:55 +00:00
Heimdall cleanup and refactor.
This commit is contained in:
parent
5e9ceebc53
commit
eb587dc299
@ -1,16 +1,5 @@
|
||||
package gay.pizza.foundation.heimdall.table
|
||||
|
||||
import org.jetbrains.exposed.sql.Table
|
||||
import org.jetbrains.exposed.sql.javatime.timestamp
|
||||
|
||||
object BlockBreakTable : Table("block_breaks") {
|
||||
val time = timestamp("time")
|
||||
val player = uuid("player")
|
||||
val world = uuid("world")
|
||||
val x = double("x")
|
||||
val y = double("y")
|
||||
val z = double("z")
|
||||
val pitch = double("pitch")
|
||||
val yaw = double("yaw")
|
||||
object BlockBreakTable : PlayerTimedLocalEventTable("block_breaks") {
|
||||
val block = text("block")
|
||||
}
|
||||
|
@ -1,16 +1,5 @@
|
||||
package gay.pizza.foundation.heimdall.table
|
||||
|
||||
import org.jetbrains.exposed.sql.Table
|
||||
import org.jetbrains.exposed.sql.javatime.timestamp
|
||||
|
||||
object BlockPlaceTable : Table("block_places") {
|
||||
val time = timestamp("time")
|
||||
val player = uuid("player")
|
||||
val world = uuid("world")
|
||||
val x = double("x")
|
||||
val y = double("y")
|
||||
val z = double("z")
|
||||
val pitch = double("pitch")
|
||||
val yaw = double("yaw")
|
||||
object BlockPlaceTable : PlayerTimedLocalEventTable("block_places") {
|
||||
val block = text("block")
|
||||
}
|
||||
|
@ -1,17 +1,6 @@
|
||||
package gay.pizza.foundation.heimdall.table
|
||||
|
||||
import org.jetbrains.exposed.sql.Table
|
||||
import org.jetbrains.exposed.sql.javatime.timestamp
|
||||
|
||||
object EntityKillTable : Table("entity_kills") {
|
||||
val time = timestamp("time")
|
||||
val player = uuid("player")
|
||||
object EntityKillTable : PlayerTimedLocalEventTable("entity_kills") {
|
||||
val entity = uuid("entity")
|
||||
val world = uuid("world")
|
||||
val x = double("x")
|
||||
val y = double("y")
|
||||
val z = double("z")
|
||||
val pitch = double("pitch")
|
||||
val yaw = double("yaw")
|
||||
val entityType = text("entity_type")
|
||||
}
|
||||
|
@ -1,16 +1,5 @@
|
||||
package gay.pizza.foundation.heimdall.table
|
||||
|
||||
import org.jetbrains.exposed.sql.Table
|
||||
import org.jetbrains.exposed.sql.javatime.timestamp
|
||||
|
||||
object PlayerAdvancementTable : Table("player_advancements") {
|
||||
val time = timestamp("time")
|
||||
val player = uuid("player")
|
||||
val world = uuid("world")
|
||||
val x = double("x")
|
||||
val y = double("y")
|
||||
val z = double("z")
|
||||
val pitch = double("pitch")
|
||||
val yaw = double("yaw")
|
||||
object PlayerAdvancementTable : PlayerTimedLocalEventTable("player_advancements") {
|
||||
val advancement = text("advancement")
|
||||
}
|
||||
|
@ -1,17 +1,6 @@
|
||||
package gay.pizza.foundation.heimdall.table
|
||||
|
||||
import org.jetbrains.exposed.sql.Table
|
||||
import org.jetbrains.exposed.sql.javatime.timestamp
|
||||
|
||||
object PlayerDeathTable : Table("player_deaths") {
|
||||
val time = timestamp("time")
|
||||
val world = uuid("world")
|
||||
val player = uuid("player")
|
||||
val x = double("x")
|
||||
val y = double("y")
|
||||
val z = double("z")
|
||||
val pitch = double("pitch")
|
||||
val yaw = double("yaw")
|
||||
object PlayerDeathTable : PlayerTimedLocalEventTable("player_deaths") {
|
||||
val experience = double("experience")
|
||||
val message = text("message").nullable()
|
||||
}
|
||||
|
@ -1,15 +1,3 @@
|
||||
package gay.pizza.foundation.heimdall.table
|
||||
|
||||
import org.jetbrains.exposed.sql.Table
|
||||
import org.jetbrains.exposed.sql.javatime.timestamp
|
||||
|
||||
object PlayerPositionTable : Table("player_positions") {
|
||||
val time = timestamp("time")
|
||||
val player = uuid("player")
|
||||
val world = uuid("world")
|
||||
val x = double("x")
|
||||
val y = double("y")
|
||||
val z = double("z")
|
||||
val pitch = double("pitch")
|
||||
val yaw = double("yaw")
|
||||
}
|
||||
object PlayerPositionTable : PlayerTimedLocalEventTable("player_positions")
|
||||
|
@ -0,0 +1,7 @@
|
||||
package gay.pizza.foundation.heimdall.table
|
||||
|
||||
abstract class PlayerTimedLocalEventTable(name: String) : TimedLocalEventTable(name) {
|
||||
val player = uuid("player")
|
||||
val pitch = double("pitch")
|
||||
val yaw = double("yaw")
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package gay.pizza.foundation.heimdall.table
|
||||
|
||||
import org.jetbrains.exposed.sql.Table
|
||||
import org.jetbrains.exposed.sql.javatime.timestamp
|
||||
|
||||
abstract class TimedEventTable(name: String) : Table(name) {
|
||||
val time = timestamp("time")
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package gay.pizza.foundation.heimdall.table
|
||||
|
||||
abstract class TimedLocalEventTable(name: String) : TimedEventTable(name) {
|
||||
val world = uuid("world")
|
||||
val x = double("x")
|
||||
val y = double("y")
|
||||
val z = double("z")
|
||||
}
|
@ -1,10 +1,6 @@
|
||||
package gay.pizza.foundation.heimdall.table
|
||||
|
||||
import org.jetbrains.exposed.sql.Table
|
||||
import org.jetbrains.exposed.sql.javatime.timestamp
|
||||
|
||||
object WorldChangeTable : Table("world_changes") {
|
||||
val time = timestamp("time")
|
||||
object WorldChangeTable : TimedEventTable("world_changes") {
|
||||
val player = uuid("player")
|
||||
val fromWorld = uuid("from_world")
|
||||
val toWorld = uuid("to_world")
|
||||
|
@ -1,17 +1,8 @@
|
||||
package gay.pizza.foundation.heimdall.view
|
||||
|
||||
import org.jetbrains.exposed.sql.Table
|
||||
import org.jetbrains.exposed.sql.javatime.timestamp
|
||||
import gay.pizza.foundation.heimdall.table.PlayerTimedLocalEventTable
|
||||
|
||||
object BlockChangeView : Table("block_changes") {
|
||||
object BlockChangeView : PlayerTimedLocalEventTable("block_changes") {
|
||||
val isBreak = bool("break")
|
||||
val time = timestamp("time")
|
||||
val player = uuid("player")
|
||||
val world = uuid("world")
|
||||
val x = double("x")
|
||||
val y = double("y")
|
||||
val z = double("z")
|
||||
val pitch = double("pitch")
|
||||
val yaw = double("yaw")
|
||||
val block = text("block")
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package gay.pizza.foundation.chaos
|
||||
|
||||
import gay.pizza.foundation.chaos.model.ChaosConfig
|
||||
import gay.pizza.foundation.chaos.model.ChaosModuleConfig
|
||||
import gay.pizza.foundation.chaos.modules.ChaosModule
|
||||
import gay.pizza.foundation.chaos.modules.ChaosModules
|
||||
import org.bukkit.boss.BarColor
|
||||
|
@ -15,19 +15,16 @@ class BlockBreak(
|
||||
val material: Material,
|
||||
val timestamp: Instant = Instant.now()
|
||||
) : HeimdallEvent() {
|
||||
constructor(event: BlockBreakEvent) : this(event.player.uniqueId, event.block.location, event.block.type)
|
||||
constructor(event: BlockBreakEvent) : this(
|
||||
event.player.uniqueId,
|
||||
event.block.location,
|
||||
event.block.type
|
||||
)
|
||||
|
||||
override fun store(transaction: Transaction) {
|
||||
transaction.apply {
|
||||
BlockBreakTable.insert {
|
||||
it[time] = timestamp
|
||||
it[player] = playerUniqueIdentity
|
||||
it[world] = location.world.uid
|
||||
it[x] = location.x
|
||||
it[y] = location.y
|
||||
it[z] = location.z
|
||||
it[pitch] = location.pitch.toDouble()
|
||||
it[yaw] = location.yaw.toDouble()
|
||||
putPlayerTimedLocalEvent(it, timestamp, location, playerUniqueIdentity)
|
||||
it[block] = material.key.toString()
|
||||
}
|
||||
}
|
||||
|
@ -15,19 +15,16 @@ class BlockPlace(
|
||||
val material: Material,
|
||||
val timestamp: Instant = Instant.now()
|
||||
) : HeimdallEvent() {
|
||||
constructor(event: BlockPlaceEvent) : this(event.player.uniqueId, event.block.location, event.block.type)
|
||||
constructor(event: BlockPlaceEvent) : this(
|
||||
event.player.uniqueId,
|
||||
event.block.location,
|
||||
event.block.type
|
||||
)
|
||||
|
||||
override fun store(transaction: Transaction) {
|
||||
transaction.apply {
|
||||
BlockPlaceTable.insert {
|
||||
it[time] = timestamp
|
||||
it[player] = playerUniqueIdentity
|
||||
it[world] = location.world.uid
|
||||
it[x] = location.x
|
||||
it[y] = location.y
|
||||
it[z] = location.z
|
||||
it[pitch] = location.pitch.toDouble()
|
||||
it[yaw] = location.yaw.toDouble()
|
||||
putPlayerTimedLocalEvent(it, timestamp, location, playerUniqueIdentity)
|
||||
it[block] = material.key.toString()
|
||||
}
|
||||
}
|
||||
|
@ -17,14 +17,7 @@ class EntityKill(
|
||||
override fun store(transaction: Transaction) {
|
||||
transaction.apply {
|
||||
EntityKillTable.insert {
|
||||
it[time] = timestamp
|
||||
it[player] = playerUniqueIdentity
|
||||
it[world] = location.world.uid
|
||||
it[x] = location.x
|
||||
it[y] = location.y
|
||||
it[z] = location.z
|
||||
it[pitch] = location.pitch.toDouble()
|
||||
it[yaw] = location.yaw.toDouble()
|
||||
putPlayerTimedLocalEvent(it, timestamp, location, playerUniqueIdentity)
|
||||
it[entity] = entityUniqueIdentity
|
||||
it[entityType] = entityTypeName
|
||||
}
|
||||
|
@ -0,0 +1,41 @@
|
||||
package gay.pizza.foundation.heimdall.plugin.event
|
||||
|
||||
import gay.pizza.foundation.heimdall.table.PlayerTimedLocalEventTable
|
||||
import gay.pizza.foundation.heimdall.table.TimedEventTable
|
||||
import gay.pizza.foundation.heimdall.table.TimedLocalEventTable
|
||||
import org.bukkit.Location
|
||||
import org.jetbrains.exposed.sql.statements.InsertStatement
|
||||
import java.time.Instant
|
||||
import java.util.*
|
||||
|
||||
fun <T : TimedEventTable, K : Any> T.putTimedEvent(statement: InsertStatement<K>, time: Instant) {
|
||||
statement[this.time] = time
|
||||
}
|
||||
|
||||
fun <T : TimedLocalEventTable, K : Any> T.putTimedLocalEvent(
|
||||
statement: InsertStatement<K>,
|
||||
time: Instant,
|
||||
location: Location
|
||||
) {
|
||||
statement[this.time] = time
|
||||
statement[this.world] = location.world.uid
|
||||
statement[this.x] = location.x
|
||||
statement[this.y] = location.y
|
||||
statement[this.z] = location.z
|
||||
}
|
||||
|
||||
fun <T : PlayerTimedLocalEventTable, K : Any> T.putPlayerTimedLocalEvent(
|
||||
statement: InsertStatement<K>,
|
||||
time: Instant,
|
||||
location: Location,
|
||||
player: UUID
|
||||
) {
|
||||
statement[this.time] = time
|
||||
statement[this.world] = location.world.uid
|
||||
statement[this.x] = location.x
|
||||
statement[this.y] = location.y
|
||||
statement[this.z] = location.z
|
||||
statement[this.player] = player
|
||||
statement[this.pitch] = location.pitch.toDouble()
|
||||
statement[this.yaw] = location.yaw.toDouble()
|
||||
}
|
@ -15,19 +15,16 @@ class PlayerAdvancement(
|
||||
val advancement: Advancement,
|
||||
val timestamp: Instant = Instant.now()
|
||||
) : HeimdallEvent() {
|
||||
constructor(event: PlayerAdvancementDoneEvent) : this(event.player.uniqueId, event.player.location, event.advancement)
|
||||
constructor(event: PlayerAdvancementDoneEvent) : this(
|
||||
event.player.uniqueId,
|
||||
event.player.location,
|
||||
event.advancement
|
||||
)
|
||||
|
||||
override fun store(transaction: Transaction) {
|
||||
transaction.apply {
|
||||
PlayerAdvancementTable.insert {
|
||||
it[time] = timestamp
|
||||
it[player] = playerUniqueIdentity
|
||||
it[world] = location.world.uid
|
||||
it[x] = location.x
|
||||
it[y] = location.y
|
||||
it[z] = location.z
|
||||
it[pitch] = location.pitch.toDouble()
|
||||
it[yaw] = location.yaw.toDouble()
|
||||
putPlayerTimedLocalEvent(it, timestamp, location, playerUniqueIdentity)
|
||||
it[advancement] = this@PlayerAdvancement.advancement.key.toString()
|
||||
}
|
||||
}
|
||||
|
@ -25,14 +25,7 @@ class PlayerDeath(
|
||||
override fun store(transaction: Transaction) {
|
||||
transaction.apply {
|
||||
PlayerDeathTable.insert {
|
||||
it[time] = timestamp
|
||||
it[player] = playerUniqueIdentity
|
||||
it[world] = location.world.uid
|
||||
it[x] = location.x
|
||||
it[y] = location.y
|
||||
it[z] = location.z
|
||||
it[pitch] = location.pitch.toDouble()
|
||||
it[yaw] = location.yaw.toDouble()
|
||||
putPlayerTimedLocalEvent(it, timestamp, location, playerUniqueIdentity)
|
||||
it[experience] = experienceLevel.toDouble()
|
||||
it[message] = deathMessage
|
||||
}
|
||||
|
@ -13,19 +13,15 @@ class PlayerPosition(
|
||||
val location: Location,
|
||||
val timestamp: Instant = Instant.now()
|
||||
) : HeimdallEvent() {
|
||||
constructor(event: PlayerMoveEvent) : this(event.player.uniqueId, event.to)
|
||||
constructor(event: PlayerMoveEvent) : this(
|
||||
event.player.uniqueId,
|
||||
event.to
|
||||
)
|
||||
|
||||
override fun store(transaction: Transaction) {
|
||||
transaction.apply {
|
||||
PlayerPositionTable.insert {
|
||||
it[time] = timestamp
|
||||
it[player] = playerUniqueIdentity
|
||||
it[world] = location.world.uid
|
||||
it[x] = location.x
|
||||
it[y] = location.y
|
||||
it[z] = location.z
|
||||
it[pitch] = location.pitch.toDouble()
|
||||
it[yaw] = location.yaw.toDouble()
|
||||
putPlayerTimedLocalEvent(it, timestamp, location, playerUniqueIdentity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ class WorldChange(
|
||||
override fun store(transaction: Transaction) {
|
||||
transaction.apply {
|
||||
WorldChangeTable.insert {
|
||||
it[time] = timestamp
|
||||
putTimedEvent(it, timestamp)
|
||||
it[player] = playerUniqueIdentity
|
||||
it[fromWorld] = fromWorldId
|
||||
it[fromWorldName] = fromWorldActualName
|
||||
|
@ -63,9 +63,9 @@ class BlockChangelog(
|
||||
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]
|
||||
val x = row[BlockChangeView.x]
|
||||
val y = row[BlockChangeView.y]
|
||||
val z = row[BlockChangeView.z]
|
||||
val block = row[gay.pizza.foundation.heimdall.view.BlockChangeView.block]
|
||||
val location = BlockCoordinate(x.toLong(), y.toLong(), z.toLong())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user