Add persistent player stats and DB support
Introduce MySQL persistence and an in-memory stats system with async saving. - Add HikariCP & MySQL connector dependencies and relocate libs in build.gradle.kts. - Add DatabaseManager (HikariCP) to manage connection pool and lifecycle. - Add PlayerStats data model and PlayerStatsRepository for table creation, reads, upserts and batch upserts (with prepared statements). - Add StatsManager: coroutine-based cache, dirty-flags, async batch saves, auto-save (every 5 minutes), load/save APIs and shutdown save. - Add StatsListener: load on AsyncPlayerPreLoginEvent and save on PlayerQuitEvent. - Wire DB and stats into main plugin: connect on enable (disable plugin on fail), initialize StatsManager, save/disconnect on disable, register leaderboard command and stats listener. - Update GameManager to record kills/wins/deaths and adjust scrimScore on events. - Add LeaderboardCommand and language entries for leaderboard output; expose command in plugin.yml. - Add database configuration section to config.yml. - Minor refactor: KitCommand plugin accessor changed to a getter. These changes provide a robust, pooled DB connection and efficient stats persistence (batched/upserted) to reduce DB load and ensure data safety during shutdown.
This commit is contained in:
@@ -23,8 +23,11 @@ repositories {
|
||||
dependencies {
|
||||
implementation("fr.mrmicky:fastboard:2.1.3")
|
||||
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT")
|
||||
implementation("com.zaxxer:HikariCP:5.1.0")
|
||||
implementation("com.mysql:mysql-connector-j:8.4.0")
|
||||
implementation(libs.kotlinxCoroutines)
|
||||
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT")
|
||||
compileOnly("com.sk89q.worldedit:worldedit-core:7.2.17-SNAPSHOT")
|
||||
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.2.17-SNAPSHOT")
|
||||
}
|
||||
@@ -42,6 +45,8 @@ tasks {
|
||||
archiveBaseName.set("GameModes-SpeedHG")
|
||||
archiveClassifier.set("")
|
||||
archiveVersion.set(project.version.toString())
|
||||
relocate("com.zaxxer.hikari", "club.mcscrims.speedhg.libs.hikari")
|
||||
relocate("com.mysql", "club.mcscrims.speedhg.libs.mysql")
|
||||
}
|
||||
|
||||
build {
|
||||
|
||||
Reference in New Issue
Block a user