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.
60 lines
1.5 KiB
Kotlin
60 lines
1.5 KiB
Kotlin
plugins {
|
|
id("java")
|
|
id("maven-publish")
|
|
id("com.github.johnrengelman.shadow") version "8.1.1"
|
|
kotlin("jvm") version "2.2.0"
|
|
kotlin("kapt") version "2.2.0"
|
|
}
|
|
|
|
group = "club.mcscrims"
|
|
version = "1.0.0"
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
maven("https://repo.papermc.io/repository/maven-public/")
|
|
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
|
maven("https://oss.sonatype.org/content/repositories/snapshots/")
|
|
maven("https://libraries.minecraft.net/")
|
|
maven("https://repo.codemc.io/repository/maven-public/")
|
|
maven("https://repo.lunarclient.dev")
|
|
maven("https://maven.enginehub.org/repo/")
|
|
}
|
|
|
|
dependencies {
|
|
implementation("fr.mrmicky:fastboard:2.1.3")
|
|
|
|
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")
|
|
}
|
|
|
|
tasks {
|
|
compileKotlin {
|
|
compilerOptions.freeCompilerArgs.set(listOf( "-Xjsr305=strict" ))
|
|
}
|
|
|
|
compileJava {
|
|
options.encoding = "UTF-8"
|
|
}
|
|
|
|
shadowJar {
|
|
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 {
|
|
dependsOn( shadowJar )
|
|
}
|
|
}
|
|
|
|
java {
|
|
toolchain.languageVersion.set(JavaLanguageVersion.of( 21 ))
|
|
}
|