mirror of
https://github.com/GayPizzaSpecifications/foundation.git
synced 2025-08-03 13:31:32 +00:00
Heimdall cleanup and refactor.
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user