Update Stats Management
This commit is contained in:
@@ -45,8 +45,6 @@ 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 {
|
||||
|
||||
@@ -85,9 +85,9 @@ class StatsManager(private val plugin: SpeedHG) {
|
||||
*
|
||||
* @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) {
|
||||
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.
|
||||
* Für Fälle wo kein `runBlocking` erwünscht ist.
|
||||
*/
|
||||
fun loadStatsAsync(uuid: UUID) {
|
||||
fun loadStatsAsync(uuid: UUID, name: String) {
|
||||
scope.launch {
|
||||
loadStats(uuid)
|
||||
loadStats(uuid, name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class StatsListener : Listener {
|
||||
fun onPreLogin(event: AsyncPlayerPreLoginEvent) {
|
||||
// Wir sind auf einem Async-Thread — runBlocking ist hier korrekt.
|
||||
runBlocking {
|
||||
plugin.statsManager.loadStats(event.uniqueId)
|
||||
plugin.statsManager.loadStats(event.uniqueId, event.name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user