Skip to content

Commit c31f2ae

Browse files
feat: extend SurfCoreApi and add Velocity-specific implementation
- Add `getOfflinePlayer(uuid)` method to `SurfCoreApi` and its implementations. - Update `getCurrentServerName()` to return non-nullable String. - Introduce `SurfCoreApiVelocityImpl` for Velocity platform with server name retrieval logic.
1 parent 5a1adc6 commit c31f2ae

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

surf-core-api/surf-core-api-common/src/main/kotlin/dev/slne/surf/core/api/common/SurfCoreApi.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ interface SurfCoreApi {
1212
fun getPlayer(name: String): SurfPlayer?
1313
fun getPlayer(uuid: UUID): SurfPlayer?
1414

15-
fun getCurrentServerName(): String?
15+
fun getCurrentServerName(): String
1616

1717
suspend fun getOfflinePlayer(name: String): SurfPlayer?
18+
suspend fun getOfflinePlayer(uuid: UUID): SurfPlayer?
1819
}

surf-core-core/surf-core-core-common/src/main/kotlin/dev/slne/surf/core/core/common/SurfCoreApiImpl.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ abstract class SurfCoreApiImpl : SurfCoreApi {
1515

1616
override suspend fun getOfflinePlayer(name: String) =
1717
surfPlayerService.getOrLoadPlayerByName(name)
18+
19+
override suspend fun getOfflinePlayer(uuid: UUID) =
20+
surfPlayerService.getOrLoadPlayerByUuid(uuid)
1821
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package dev.slne.surf.core.velocity.api
2+
3+
import com.google.auto.service.AutoService
4+
import dev.slne.surf.core.api.common.SurfCoreApi
5+
import dev.slne.surf.core.core.common.SurfCoreApiImpl
6+
import dev.slne.surf.core.velocity.surfServerConfig
7+
import net.kyori.adventure.util.Services
8+
9+
@AutoService(SurfCoreApi::class)
10+
class SurfCoreApiVelocityImpl : SurfCoreApiImpl(), Services.Fallback {
11+
override fun getCurrentServerName() = surfServerConfig.serverName
12+
}

0 commit comments

Comments
 (0)