Skip to content

Commit 03cee82

Browse files
feat: add SurfCoreApiPaperImpl and server name retrieval
- Introduce `SurfCoreApiPaperImpl` implementation extending `SurfCoreApiImpl` for Paper-specific logic. - Add `getCurrentServerName` method to `SurfCoreApi` and its
1 parent 0a20a89 commit 03cee82

File tree

3 files changed

+15
-4
lines changed
  • surf-core-api/surf-core-api-common/src/main/kotlin/dev/slne/surf/core/api/common
  • surf-core-core/surf-core-core-common/src/main/kotlin/dev/slne/surf/core/core/common
  • surf-core-paper/src/main/kotlin/dev/slne/surf/core/paper/api

3 files changed

+15
-4
lines changed

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

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

15+
fun getCurrentServerName(): String?
16+
1517
suspend fun getOfflinePlayer(name: String): SurfPlayer?
1618
}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
package dev.slne.surf.core.core.common
22

3-
import com.google.auto.service.AutoService
43
import dev.slne.surf.core.api.common.SurfCoreApi
54
import dev.slne.surf.core.api.common.player.SurfPlayer
65
import dev.slne.surf.core.core.common.player.surfPlayerService
76
import it.unimi.dsi.fastutil.objects.ObjectSet
8-
import net.kyori.adventure.util.Services
97
import java.util.*
108

11-
@AutoService(SurfCoreApi::class)
12-
class SurfCoreApiImpl : SurfCoreApi, Services.Fallback {
9+
abstract class SurfCoreApiImpl : SurfCoreApi {
1310
override fun getOnlinePlayers(): ObjectSet<SurfPlayer> = surfPlayerService.players
1411

1512
override fun getPlayer(name: String) = surfPlayerService.findPlayerByName(name)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package dev.slne.surf.core.paper.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.paper.surfServerConfig
7+
import net.kyori.adventure.util.Services
8+
9+
@AutoService(SurfCoreApi::class)
10+
class SurfCoreApiPaperImpl : SurfCoreApiImpl(), Services.Fallback {
11+
override fun getCurrentServerName() = surfServerConfig.serverName
12+
}

0 commit comments

Comments
 (0)