Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.

Commit 3caf083

Browse files
authored
Merge branch 'master' into cleanup-dead-code
2 parents 8ee737f + a8d7e46 commit 3caf083

File tree

9 files changed

+43
-18
lines changed

9 files changed

+43
-18
lines changed

surf-cloud-api/surf-cloud-api-common/src/main/kotlin/dev/slne/surf/cloud/api/common/SurfCloudApplication.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration
66
import org.springframework.boot.autoconfigure.domain.EntityScan
77
import org.springframework.boot.context.TypeExcludeFilter
88
import org.springframework.cache.annotation.EnableCaching
9-
import org.springframework.context.annotation.AdviceMode
109
import org.springframework.context.annotation.ComponentScan
1110
import org.springframework.context.annotation.FilterType
1211
import org.springframework.scheduling.annotation.EnableAsync
@@ -25,7 +24,7 @@ import java.lang.annotation.Inherited
2524
@EnableScheduling
2625
@EnableAsync(mode = AdviceMode.ASPECTJ)
2726
@EntityScan
28-
@EnableCaching(mode = AdviceMode.ASPECTJ)
27+
@EnableCaching
2928
@AutoConfigurationPackage
3029
@Inherited
3130
@EnableAutoConfiguration

surf-cloud-api/surf-cloud-api-server/src/main/kotlin/dev/slne/surf/cloud/api/server/exposed/columns/ComponentColumnType.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ComponentColumnType : ColumnType<Component>() {
1919
else -> error("Unexpected value of type Component: $value of ${value::class.qualifiedName}")
2020
}
2121

22-
override fun nonNullValueToString(value: Component): String =
22+
override fun notNullValueToDB(value: Component): Any =
2323
GsonComponentSerializer.gson().serialize(value)
2424
}
2525

surf-cloud-api/surf-cloud-api-server/src/main/kotlin/dev/slne/surf/cloud/api/server/plugin/AdditionalStandaloneConfiguration.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ import kotlin.coroutines.startCoroutine
5858
)
5959
annotation class AdditionalStandaloneConfiguration
6060

61+
@AdditionalStandaloneConfiguration
62+
class PluginConfig
63+
6164

6265
@EnableTransactionManagement(mode = AdviceMode.ASPECTJ)
6366
@Configuration

surf-cloud-core/surf-cloud-core-client/src/main/kotlin/dev/slne/surf/cloud/core/client/player/ClientCloudPlayerImpl.kt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ import dev.slne.surf.cloud.core.common.netty.network.protocol.running.serverboun
7777

7878
abstract class ClientCloudPlayerImpl<PlatformPlayer : Audience>(
7979
uuid: UUID,
80-
name: String,
81-
private val createIfNotExists: Boolean
80+
name: String
8281
) : CommonCloudPlayerImpl(uuid, name) {
8382
@Volatile
8483
var proxyServerUid: Long? = null
@@ -99,12 +98,6 @@ abstract class ClientCloudPlayerImpl<PlatformPlayer : Audience>(
9998

10099
protected abstract val platformClass: Class<PlatformPlayer>
101100

102-
init {
103-
if (createIfNotExists && player == null) {
104-
ServerboundCreateOfflineCloudPlayerIfNotExistsPacket(uuid).fireAndForget()
105-
}
106-
}
107-
108101
override suspend fun latestIpAddress(): Inet4Address {
109102
return request<IpAddress>(DataRequestType.LATEST_IP_ADDRESS).ip
110103
?: error("Failed to get IP address")

surf-cloud-core/surf-cloud-core-client/src/main/kotlin/dev/slne/surf/cloud/core/client/player/CommonClientCloudPlayerManagerImpl.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ abstract class CommonClientCloudPlayerManagerImpl<Platform : Audience, P : Clien
4444
return player.serverUid
4545
}
4646

47-
override fun getOfflinePlayer(uuid: UUID): CommonOfflineCloudPlayerImpl { // FIXME: 24.07.2025 15:15 Fix create if not exists
48-
return OfflineCloudPlayerImpl(uuid)
47+
override fun getOfflinePlayer(uuid: UUID, createIfNotExists: Boolean): CommonOfflineCloudPlayerImpl {
48+
return OfflineCloudPlayerImpl(uuid, createIfNotExists)
4949
}
5050

5151
abstract fun getAudience(uuid: UUID): Audience?

surf-cloud-core/surf-cloud-core-client/src/main/kotlin/dev/slne/surf/cloud/core/client/player/OfflineCloudPlayerImpl.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package dev.slne.surf.cloud.core.client.player
22

33
import dev.slne.surf.cloud.api.client.netty.packet.fireAndAwaitOrThrow
4+
import dev.slne.surf.cloud.api.client.netty.packet.fireAndForget
45
import dev.slne.surf.cloud.api.common.player.name.NameHistory
56
import dev.slne.surf.cloud.api.common.player.playtime.Playtime
67
import dev.slne.surf.cloud.core.common.netty.network.protocol.running.serverbound.ServerboundRequestPlayerDataPacket
78
import dev.slne.surf.cloud.core.common.netty.network.protocol.running.serverbound.ServerboundRequestPlayerDataPacket.DataRequestType
89
import dev.slne.surf.cloud.core.common.netty.network.protocol.running.serverbound.getGenericValue
10+
import dev.slne.surf.cloud.core.common.netty.network.protocol.running.ServerboundCreateOfflineCloudPlayerIfNotExistsPacket
11+
import dev.slne.surf.cloud.core.common.netty.network.protocol.running.getGenericValue
912
import dev.slne.surf.cloud.core.common.player.CommonOfflineCloudPlayerImpl
1013
import dev.slne.surf.surfapi.core.api.messages.Colors
1114
import dev.slne.surf.surfapi.core.api.messages.adventure.text
@@ -14,7 +17,14 @@ import java.net.Inet4Address
1417
import java.time.ZonedDateTime
1518
import java.util.*
1619

17-
class OfflineCloudPlayerImpl(uuid: UUID) : CommonOfflineCloudPlayerImpl(uuid) {
20+
class OfflineCloudPlayerImpl(uuid: UUID, createIfNotExists: Boolean) :
21+
CommonOfflineCloudPlayerImpl(uuid) {
22+
init {
23+
if (createIfNotExists && player == null) {
24+
ServerboundCreateOfflineCloudPlayerIfNotExistsPacket(uuid).fireAndForget()
25+
}
26+
}
27+
1828
override suspend fun nameHistory(): NameHistory {
1929
return request(DataRequestType.NAME_HISTORY)
2030
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class CloudCoreInstance : CloudInstance {
164164
val joinClassLoader = JoinClassLoader(classLoader, parentClassLoader)
165165
return tempChangeSystemClassLoader(joinClassLoader) {
166166
val parentContext = internalContext ?: error("Parent context is not initialized yet.")
167-
val resourceLoader = DefaultResourceLoader(joinClassLoader)
167+
val resourceLoader = DefaultResourceLoader(JoinClassLoader(joinClassLoader, listOf(javaClass.classLoader)))
168168
val childConfigurations =
169169
parentContext.getBeansOfType(CloudChildSpringApplicationConfiguration::class.java)
170170

surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/netty/server/connection/ServerConnectionListener.kt

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,16 @@ class ServerConnectionListener(val server: NettyServerImpl) {
209209
val activeProtocols = packet.protocols
210210
for (connection in connections) {
211211
if (connection.outboundProtocolInfo.id !in activeProtocols) continue
212-
connection.send(packet, flush)
212+
213+
try {
214+
connection.send(packet, flush)
215+
} catch (e: Throwable) {
216+
log.atWarning()
217+
.withCause(e)
218+
.log(
219+
"Failed to broadcast packet ${packet::class.simpleName} to ${connection.getLoggableAddress(logIps)}"
220+
)
221+
}
213222
}
214223
}
215224

@@ -222,7 +231,16 @@ class ServerConnectionListener(val server: NettyServerImpl) {
222231

223232
for (connection in connections) {
224233
if (connection.outboundProtocolInfo.id !in activeProtocols) continue
225-
connection.send(packet, flush)
234+
235+
try {
236+
connection.send(packet, flush)
237+
} catch (e: Throwable) {
238+
log.atWarning()
239+
.withCause(e)
240+
.log(
241+
"Failed to broadcast packet ${packet::class.simpleName} to ${connection.getLoggableAddress(logIps)}"
242+
)
243+
}
226244
}
227245
}
228246

surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/plugin/spring/PluginDatabaseConfigModern.kt renamed to surf-cloud-standalone/src/main/kotlin/dev/slne/surf/cloud/standalone/plugin/spring/PluginSpringConfig.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dev.slne.surf.cloud.standalone.plugin.spring
22

3+
import dev.slne.surf.cloud.api.server.plugin.PluginConfig
34
import dev.slne.surf.cloud.api.server.plugin.configuration.PluginMeta
45
import dev.slne.surf.cloud.api.server.plugin.provider.classloader.SpringPluginClassloader
56
import dev.slne.surf.cloud.core.common.spring.CloudChildSpringApplicationConfiguration
@@ -15,7 +16,7 @@ import org.springframework.boot.builder.SpringApplicationBuilder
1516
import org.springframework.stereotype.Component
1617

1718
@Component
18-
class PluginDatabaseConfigModern : CloudChildSpringApplicationConfiguration {
19+
class PluginSpringConfig : CloudChildSpringApplicationConfiguration {
1920

2021
override fun configureChildApplication(
2122
builder: SpringApplicationBuilder,
@@ -43,6 +44,7 @@ class PluginDatabaseConfigModern : CloudChildSpringApplicationConfiguration {
4344
PluginDatasourceConfiguration::class.java,
4445
PluginFlywayConfigurationCustomizer::class.java,
4546
ExposedAutoConfiguration::class.java,
47+
PluginConfig::class.java
4648
)
4749
}
4850
}

0 commit comments

Comments
 (0)