Update Stats Management
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user