Update Stats Management

This commit is contained in:
TDSTOS
2026-03-26 01:07:12 +01:00
parent 2d720d962c
commit 0043a3e82c
3 changed files with 5 additions and 7 deletions

View File

@@ -45,8 +45,6 @@ tasks {
archiveBaseName.set("GameModes-SpeedHG") archiveBaseName.set("GameModes-SpeedHG")
archiveClassifier.set("") archiveClassifier.set("")
archiveVersion.set(project.version.toString()) archiveVersion.set(project.version.toString())
relocate("com.zaxxer.hikari", "club.mcscrims.speedhg.libs.hikari")
relocate("com.mysql", "club.mcscrims.speedhg.libs.mysql")
} }
build { build {

View File

@@ -85,9 +85,9 @@ class StatsManager(private val plugin: SpeedHG) {
* *
* @return Das [PlayerStats]-Objekt (neu aus DB oder aus Cache). * @return Das [PlayerStats]-Objekt (neu aus DB oder aus Cache).
*/ */
suspend fun loadStats(uuid: UUID): PlayerStats = withContext(Dispatchers.IO) { suspend fun loadStats(uuid: UUID, name: String): PlayerStats = withContext(Dispatchers.IO) {
cache.getOrPut(uuid) { cache.getOrPut(uuid) {
repository.findByUUID(uuid) ?: PlayerStats(uuid) // Neuer Spieler → Defaults repository.findByUUID(uuid) ?: PlayerStats(uuid, name) // Neuer Spieler → Defaults
} }
} }
@@ -95,9 +95,9 @@ class StatsManager(private val plugin: SpeedHG) {
* Startet das Laden im Hintergrund ohne zu warten. * Startet das Laden im Hintergrund ohne zu warten.
* Für Fälle wo kein `runBlocking` erwünscht ist. * Für Fälle wo kein `runBlocking` erwünscht ist.
*/ */
fun loadStatsAsync(uuid: UUID) { fun loadStatsAsync(uuid: UUID, name: String) {
scope.launch { scope.launch {
loadStats(uuid) loadStats(uuid, name)
} }
} }

View File

@@ -38,7 +38,7 @@ class StatsListener : Listener {
fun onPreLogin(event: AsyncPlayerPreLoginEvent) { fun onPreLogin(event: AsyncPlayerPreLoginEvent) {
// Wir sind auf einem Async-Thread — runBlocking ist hier korrekt. // Wir sind auf einem Async-Thread — runBlocking ist hier korrekt.
runBlocking { runBlocking {
plugin.statsManager.loadStats(event.uniqueId) plugin.statsManager.loadStats(event.uniqueId, event.name)
} }
} }