Skip to content

Commit 8593f98

Browse files
[autofix.ci] apply automated fixes
1 parent 5ad8197 commit 8593f98

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

plugin/src/main/kotlin/dev/betrix/superSmashMobsBrawl/services/PlayerDocumentService.kt

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import dev.betrix.superSmashMobsBrawl.extensions.warn
88
import dev.betrix.superSmashMobsBrawl.models.player.PlayerDocument
99
import gg.flyte.twilight.event.event
1010
import gg.flyte.twilight.scheduler.repeatingTask
11+
import java.util.UUID
1112
import kotlin.time.Duration.Companion.minutes
1213
import kotlinx.coroutines.Dispatchers
1314
import kotlinx.coroutines.runBlocking
@@ -18,7 +19,6 @@ import org.bukkit.event.player.PlayerJoinEvent
1819
import org.bukkit.event.player.PlayerQuitEvent
1920
import org.koin.core.component.KoinComponent
2021
import org.koin.core.component.inject
21-
import java.util.UUID
2222

2323
object PlayerDocumentService : KoinComponent, Manageable() {
2424
private val api: ApiService by inject()
@@ -45,7 +45,10 @@ object PlayerDocumentService : KoinComponent, Manageable() {
4545
val player = plugin.server.getPlayer(uuid)
4646

4747
if (player == null) {
48-
plugin.logger.warn("Player with UUID {uuid} not found, removing from cache and skipping persistence.", uuid)
48+
plugin.logger.warn(
49+
"Player with UUID {uuid} not found, removing from cache and skipping persistence.",
50+
uuid,
51+
)
4952
documents.remove(uuid)
5053
return@withContext
5154
}
@@ -55,7 +58,7 @@ object PlayerDocumentService : KoinComponent, Manageable() {
5558
plugin.logger.warn(
5659
"Failed to persist document for {playerName}: {errorMessage}",
5760
player.name,
58-
it.message ?: "No error message"
61+
it.message ?: "No error message",
5962
)
6063
}
6164
}
@@ -97,14 +100,21 @@ object PlayerDocumentService : KoinComponent, Manageable() {
97100
val player = plugin.server.getPlayer(uuid)
98101

99102
if (player == null) {
100-
plugin.logger.warn("Player with UUID {uuid} not found, skipping persistence.", uuid)
103+
plugin.logger.warn(
104+
"Player with UUID {uuid} not found, skipping persistence.",
105+
uuid,
106+
)
101107
return@forEach
102108
}
103109

104110
withContext(Dispatchers.IO) {
105111
runCatching { api.playersSetDocumentAsync(player, doc) }
106112
.onFailure {
107-
plugin.logger.warn("Flush failed for {playerName}: {errorMessage}", player.name, it.message ?: "No error message")
113+
plugin.logger.warn(
114+
"Flush failed for {playerName}: {errorMessage}",
115+
player.name,
116+
it.message ?: "No error message",
117+
)
108118
}
109119
}
110120
}
@@ -113,16 +123,17 @@ object PlayerDocumentService : KoinComponent, Manageable() {
113123
}
114124

115125
fun getPlayerDocument(player: Player): PlayerDocument =
116-
documents[player.uniqueId] ?: error("Player document for ${player.name} not found in cache.")
117-
118-
fun getPlayerDocumentOrNull(player: Player): PlayerDocument? =
119126
documents[player.uniqueId]
127+
?: error("Player document for ${player.name} not found in cache.")
128+
129+
fun getPlayerDocumentOrNull(player: Player): PlayerDocument? = documents[player.uniqueId]
120130

121131
suspend fun getPlayerDocumentOrFetch(player: Player): PlayerDocument {
122-
return documents[player.uniqueId] ?: withContext(Dispatchers.IO) {
123-
val document = api.playersGetDocumentAsync(player, true)
124-
documents[player.uniqueId] = document
125-
document
126-
}
132+
return documents[player.uniqueId]
133+
?: withContext(Dispatchers.IO) {
134+
val document = api.playersGetDocumentAsync(player, true)
135+
documents[player.uniqueId] = document
136+
document
137+
}
127138
}
128139
}

0 commit comments

Comments
 (0)